Get the changed uploaded file name
Hi! I get the uploaded filename from this script (from client side) :
$('#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)
So you want them to be overwritten?
No. I just was saing that it would be better if the php file would return the name the file was saved in server. So there will not be neccesery to create sessions to keep the filename but just get it from ajax request when the file has finished uploading.
and....
done: function (e, data) { $.each(data.files, function (index, file) { alert(data.result[0].name); });
Please read: https://github.com/blueimp/jQuery-File-Upload#support
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); });