0

I have a Java servlet running on JBoss.
Now i need to upload a document file from an swf using as3's FileReference Class. I get the request to the servlet and the response back in flash.
But how can i access the data/file sent from as3 with the FileReference POST?!?!

     @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String userName = request.getParameter("userName");
        logger.info("POST request from as3 ");
        logger.info("userName " + userName); // I recive the parameter sent by URLVariables in as3 fine
        String fileName = request.getParameter("Filename");
        logger.info("filename " + fileName); // null
        String fileData = request.getParameter("Filedata");
        logger.info("fileData " + fileData); // null

        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        out.write("success=1"); // I recive this parameter in the swf
        out.close();
    }

I'm testing with a 'test.txt' file, but later need to be able to upload any Text Document.

How to access the Data/File??

M4tchB0X3r
  • 1,531
  • 1
  • 15
  • 28
  • I would imagine it works the same as any multipart/form-data submission, so take a look at the Apache Commons Fileupload library. – developerwjk Jan 23 '14 at 21:02
  • 1
    possible duplicate of [How to upload files to server using JSP/Servlet?](http://stackoverflow.com/questions/2422468/how-to-upload-files-to-server-using-jsp-servlet) – The_asMan Jan 23 '14 at 21:03
  • thx, the @MultipartConfig anotation from the link brought me to the solution! – M4tchB0X3r Jan 23 '14 at 22:13

0 Answers0