ProgerXP / FileDrop

Self-contained cross-browser pure JavaScript class for Drag & Drop and AJAX (multi) file upload.
filedropjs.org
The Unlicense
264 stars 61 forks source link

How to get server's response when using jQuery interface? #25

Open ProgerXP opened 10 years ago

ProgerXP commented 10 years ago

I would like to use the jQuery interface but how is it possible to get the server's response on 'filedone'? I would like the server to rename the uploaded file to avoid collisions and pass the new name back to the web page.

Simply use XHR object given to 'done' event as in $().on('filedone', function (e, file, xhr)) - e.g. its responseText field to get whatever was output by the server. Note that it won't work for iframe (if you're using it) - see the docs for iframeDone and the comment about filedone in the source code around the end of the file.