Hi,
I am using Uploadify at my workplace and I am using a Java Servlet as a backend script.
I am able to successfully invoke the Servlet but when I set 'multi' as 'true' for multiple files upload and invoke '$('#fileInput').uploadifyUpload()' - I see the progress bar advancing to 100% only for the first file selected and it does not advance to the next file. Even my Servlet is executed only once.
However I have tested it with the backend script being the default uploadify.php and it works fine. I am not sure why its not working when the back-end script is a Java Servlet. Below are the code snippets:
JSP with Uploadify Plugin which calls the Servlet:
$(document).ready(function() {
$('#fileInput').uploadify({ 'uploader' : 'swf/uploadify.swf', 'script' : 'uploadifyServlet', 'cancelImg' : 'img/cancel.png', 'multi' : true, 'folder' : '/uploads', });
$('#upload').click(function() { $('#fileInput').uploadifyUpload(); });
});
a href="#" id="upload" >Upload Files | a href="javascript:$('#fileInput').uploadifyClearQueue();" >Clear Queue
Servlet:
package test;
import java.io.*; import java.util.List;
import javax.servlet.http.; import javax.servlet.;
import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload;
public class UploadifyServlet extends HttpServlet { public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { System.out.println("UploadServlet invoked. Here are all uploaded files: ");
try {
List items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(req);
for (FileItem item : items) { if (!item.isFormField()) { System.out.println("Name: " + item.getName()); System.out.println("Size: " + item.getSize()); System.out.println("Type: " + item.getContentType()); } } } catch (Exception e) { throw new ServletException(e); } } }
web.xml - which has the Servlet mapping:
uploadifyServlet test.UploadifyServlet
uploadifyServlet /uploadifyServlet
Any help is highly appreciated as I urgently need assistance for this issue. Looking forward to a solution ...Thanks...