How to get the current uploading file name
I am trying to get the current uploading file name (at the beginning of upload process. I know there are these two callbacks:
send: function (e, data) and submit: function (e, data). But not sure how to get the data from the data.
Thanks.
Got it. It is in the the send: function (e, data) {data.files[0];}
You can do this way
$('#fileupload').bind('fileuploadadded', function (e, data) { $.each(data.files, function (index, file) { alert('filename: ' + file.name + '\n'); }); });
Hi. Another way of findin that is:
$('#fileupload').fileupload({ done : function (e, data){ filess = data.files; filenam = filess[0].name; } });
This will give the name of the file that we drag to upload, but if this file exists in the upload folder it will be renamed to filename(1).filetype, filename(2).filetype etc.
How can we return this filename
(because users may upload different files with same name, so we cant overwrite them)
You can do this by this way:
Bind this event to $('#fileupload');
.bind('fileuploaddone', function (e, data) { $.each(data.result.files, function (index, file) { console.log(data.result.files[index].name); });