[opencms-dev] upload a file

Andrea Frittoli lorblond at inwind.it
Tue May 27 16:29:01 CEST 2003


I'm trying to upload a files from a JSP page in the OpenCMS VFS. 
When I'm logged in the workplace as admin, if I lock the "uploads"
directory, everything works fine.
If I publish the project, and logout from the workplace, I get an
exception, it seems guest doesn't have the rights to write in the
"uploads" directory (but I granted read/write access to guests)

I tried also something like


but I get an "Access Denied" exception!

This is the JSP code:

<form method="post" enctype="multipart/form-data" action="#">
      <b>Select a file and submit!</b>
      <input type="file" name="uploader"/>
      <input type="submit" value="upload!"/>
<%String WORKING_PATH="/andrea/uploads/";
  com.opencms.file.CmsObject cms =
  com.opencms.file.CmsRequestContext reqContext =
  com.opencms.core.CmsRequestHttpServlet req =
  java.util.Enumeration files = req.getFileNames();
    String this_filename = (String) files.nextElement();
    byte[] filecontent = req.getFile(this_filename);
    cms.createResource(WORKING_PATH, this_filename, "binary", null,

what's wrong in this JSP? please help! 

Andrea Frittoli

More information about the opencms-dev mailing list