[opencms-dev] upload a file
Andrea Frittoli
lorblond at inwind.it
Tue May 27 16:29:01 CEST 2003
hi,
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
cms.loginUser("admin",password)
cms.lockResource(WORKING_PATH);
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"/>
<br/>
<input type="submit" value="upload!"/>
</form>
<%String WORKING_PATH="/andrea/uploads/";
com.opencms.file.CmsObject cms =
((com.opencms.flex.cache.CmsFlexRequest)request).getCmsObject();
com.opencms.file.CmsRequestContext reqContext =
cms.getRequestContext();
com.opencms.core.CmsRequestHttpServlet req =
(com.opencms.core.CmsRequestHttpServlet)(reqContext.getRequest());
java.util.Enumeration files = req.getFileNames();
while(files.hasMoreElements()){
String this_filename = (String) files.nextElement();
byte[] filecontent = req.getFile(this_filename);
cms.createResource(WORKING_PATH, this_filename, "binary", null,
filecontent);
}%>
what's wrong in this JSP? please help!
TIA
Andrea Frittoli
More information about the opencms-dev
mailing list