Thank you very much for code! <br><br><div class="gmail_quote">2011/6/28 Yves Glodt <span dir="ltr"><<a href="mailto:yg@mind.lu">yg@mind.lu</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Thanks go to Michael, I got it working with his suggestion. Here my final code:<br><br><br><br><pre><div class="im"><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" session="false" %>
<%@ page import="java.io.*, java.lang.*, java.util.*, java.text.*" %>
<%@ page import="javax.servlet.*, javax.servlet.http.*" %>
<%@ page import="org.opencms.*, org.opencms.main.*, org.opencms.flex.*, org.opencms.jsp.*, org.opencms.file.*, org.opencms.file.types.*" %>
<%@ page import="org.apache.commons.lang.*" %>
<%@ page import="org.apache.commons.fileupload.*, org.apache.commons.fileupload.disk.*, org.apache.commons.fileupload.</div>servlet.*" %>
<%

if (!request.getMethod().equals("POST")) {
        response.sendRedirect("<a href="http://my.site.biz/" target="_blank">http://my.site.biz/</a>");
        return;
}

FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);

List<FileItem> items = null;

try {
        items = upload.parseRequest(request);
} catch (FileUploadException e) {
        out.println("Error parsing request");
        System.out.println(request.getRemoteAddr()+": Import: Error parsing request.");
        return;
}

Iterator<FileItem> iter = items.iterator();

Integer no_dossier = null;
String no_article = null;
String filename = null;
byte[] bytes = null;

while (iter.hasNext()) {
        FileItem item = (FileItem) iter.next();

        if (item.isFormField()) {

                if (item.getFieldName().equals("no_dossier")) {
                        no_dossier = Integer.parseInt(item.getString());
                }

                if (item.getFieldName().equals("no_article")) {
                        no_article = item.getString();
                }

        } else {
                filename = item.getName();
                bytes = item.get();
        }
}

try {

        CmsObject cms = OpenCms.initCmsObject("Guest");
        cms.loginUser("contentcreator", "thepassword");

        CmsProject project = cms.readProject("Offline");
        cms.getRequestContext().setCurrentProject(project);

        cms.getRequestContext().setSiteRoot("/sites/<a href="http://my.site.biz/" target="_blank">my.site.biz/</a>");
        

        if (!cms.existsResource("/images")) {
                System.out.println("Creating /images");
                cms.createResource("/images", CmsResourceTypeFolder.RESOURCE_TYPE_ID);
        }

        if (!cms.existsResource("/images/articles")) {
                System.out.println("Creating /images/articles");
                cms.createResource("/images/articles", CmsResourceTypeFolder.RESOURCE_TYPE_ID);
        }

        if (!cms.existsResource("/images/articles/"+no_dossier)) {
                System.out.println("Creating /images/articles/"+no_dossier);
                cms.createResource("/images/articles/"+no_dossier, CmsResourceTypeFolder.RESOURCE_TYPE_ID);
        }

        if (!cms.existsResource("/images/articles/"+no_dossier+"/"+no_article)) {
                System.out.println("Creating /images/articles/"+no_dossier+"/"+no_article);
                cms.createResource("/images/articles/"+no_dossier+"/"+no_article, CmsResourceTypeFolder.RESOURCE_TYPE_ID);
        }

        String newResname = cms.getRequestContext().getFileTranslator().translateResource("/images/articles/"+no_dossier+"/"+no_article+"/" + filename);
        int resTypeId = OpenCms.getResourceManager().getDefaultTypeForName(filename).getTypeId();
        cms.createResource(newResname, resTypeId, bytes, null);

        //cms.unlockResource("/images/articles");
        //cms.unlockResource("/images/articles/"+no_dossier);
        //cms.unlockResource("/images/articles/"+no_dossier+"/"+no_article);

        cms.publishResource("/images/articles");
        //OpenCms.getPublishManager().publishResource(cms, folder);
        //OpenCms.getPublishManager().waitWhileRunning();

} catch (Exception e) {
        out.println("Error: "+e.getMessage() );
}

%></pre><div><div></div><div class="h5"><br></div></div></blockquote></div><br>-- <br><i><div><span style="font-style:normal"><i><div><span style="font-style:normal"><i><div style="display:inline !important"><span style="font-style:normal"><i><a href="http://www.solutioncms.com" target="_blank">www.solutioncms.com</a></i></span></div>
</i></span></div><div><span style="font-style:normal"><i><span style="font-style:normal"><i><div><span style="font-style:normal"><i><div style="display:inline !important"><span style="font-style:normal"><i><span style="font-style:normal"><i><div style="display:inline !important">
<i>The Brazilian </i><span style="font-style:normal"><i><div style="display:inline !important"><span style="font-style:normal"><i><span style="font-style:normal"><i><div style="display:inline !important"><i>Official Provider OpenCms</i></div>
</i></span></i></span></div></i></span></div></i></span></i></span></div></i></span></div></i></span></i></span></div></i></span></div></i><br>