[opencms-dev] Upload new resource to Opencms

Umar Iqbal uiqbal at lmkt.com
Thu Nov 7 09:26:22 CET 2013


Hello,

I'm trying to use  CmsNewResourceUpload to upload files to opencms. It 
uploads the file successfully but however not in the specified folder. All 
i want is to give users choice to select files from there desktop  and 
upload it to OpenCMS. I need help to save it to specified folder, 
currently it saves it into root directory i.e. where the uploadfile.jsp 
page resides. 
 My code.

<%@ page import="org.opencms.workplace.explorer.*" %>
<%@ page import="org.opencms.jsp.CmsJspActionElement" %>
<%@ page import="javax.servlet.http.*" %>

 <%
 CmsJspActionElement cms = new CmsJspActionElement(pageContext, 
request,response);
 CmsNewResourceUpload upload = new CmsNewResourceUpload(cms);
 String str=request.getParameter("file");
 upload.setParamUploadFile (str) ;

     out.println("<html>");
      out.println("<head>");
      out.println("<title>Servlet upload</title>"); 
      out.println("</head>");
      out.println("<body>");
      out.println("<p>UpLoadFile"+upload.getParamUploadFile()+"</p>");

 
upload.setParamUploadFolder("/system/modules/my.first.template/resources/data/");
 upload.setParamUploadError("Error while Uploading") ;
 upload.setParamUnzipFile("false") ;

 String str1=upload.getParamUploadFolder() ;

   out.println("<p>"+str1+"</p>"); 
  upload.actionUpload () ;
       out.println("</body>");
      out.println("</html>");
 %>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20131107/6779b611/attachment.htm>


More information about the opencms-dev mailing list