jQuery-File-Upload icon indicating copy to clipboard operation
jQuery-File-Upload copied to clipboard

How to get the current uploading file name

Open rfcongithub opened this issue 14 years ago • 4 comments

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.

rfcongithub avatar Apr 07 '12 01:04 rfcongithub

Got it. It is in the the send: function (e, data) {data.files[0];}

rfcongithub avatar Apr 07 '12 16:04 rfcongithub

You can do this way

$('#fileupload').bind('fileuploadadded', function (e, data) { $.each(data.files, function (index, file) { alert('filename: ' + file.name + '\n'); }); });

kiranvolety avatar Apr 07 '12 16:04 kiranvolety

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)

domeri avatar Aug 08 '12 10:08 domeri

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); });

cpeeyush avatar May 25 '13 12:05 cpeeyush