views:

184

answers:

2

Hi everyone,

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.

A: 

Try to use firebug to see what exactly is sent to a server. At the very least you'll see where error happens (in JS code or on serverside)

Juriy
Well, I cannot see anything on the console being sent. But when I look at DOM > window > settings (settings of the uploadify), I can see settings I'd applied, but I cannot see scriptData setting. Any recommendations?
kubilayeksioglu
Well that's weird, if you see that nothing is sent in Firebug, still you see server output this means that firebug is not tracking network.
Juriy
+1  A: 

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.

axtavt
Exactly, he needs to use the very same file upload API as well to grab the "plain vanilla" request parameters.
BalusC
Thanks a lot, I used `FileItem.getString` instead and it works like charm now.
kubilayeksioglu