Search code examples
javajqueryservletsuploadify

Uploadify uploadSettings with scriptData does not work


I am sending a file to my Java Servlet via jQuery Uploadify, there are no problems while sending the actual file. But when I try to send some scriptData with file along, to process on Servlet it just does not send anything.

Here is the JS code:

$("button").click(function(){
        $("#uploadify").uploadifySettings('scriptData', {'length':'0.2'});
        $('#uploadify').uploadifyUpload();
});

$('#uploadify').uploadify({
    'uploader': 'assets/uploadify/uploadify.swf',
    'script': 'upload',
    'folder': '/uploads'
});

And here is the Servlet code on the server side:

out.println(res.getParameter("length"));

Only output I get is null, while expecting "0.2". I just cannot get what's wrong and any kind of help will be appreciated.

Thanks in advance.


Solution

  • How do you handle uploaded file at the server side?

    getParameter() doesn't work if you read the request body manually. You may use Commons FileUpload filter to read uploaded files and parameters simultaneously.