Last post Jun 13, 2016 01:40 PM by PatriceSc
Jun 08, 2016 08:48 PM|dlchase|LINK
We have an asp.net page that allows the user to select multiple files to upload and then click a button to actually upload the files. Is it possible in js or jquery to rename the file selected/taken each time a file is selected. The reason is that one
of our users is trying to upload from our page on an iPhone and all files are being named image.jpeg so they conflict once the 2nd file is selected. The smartphone allows for a camera (immediate photo) so a user will take a picture, select browse again, take
another picture, etc. Then all files are streamed up to the server.
Jun 09, 2016 03:09 AM|Fei Han - MSFT|LINK
one of our users is trying to upload from our page on an iPhone and all files are being named image.jpeg so they conflict once the 2nd file is selected.
Safari on iOS always naming uploading image image.jpg seems a known issue
You could try to give a feedback.
Jun 09, 2016 12:41 PM|dlchase|LINK
I have no problem renaming during upload but was trying to rename each file when it is taken by the camera
before the upload.
Jun 13, 2016 11:20 AM|PatriceSc|LINK
I don't see how it could be done. It seems that by design all selected files are posted with the same name as a safety measure. So you'll have to take this into account when writing your code.
A common approach is to save the file name to a db and name the file using some unique server side generated name. This way you can store multiple files even if they have the same file name.
Jun 13, 2016 01:12 PM|dlchase|LINK
It seems that by design all selected files are posted with the same name as a safety measure
Not sure what you mean by this as only iPhone has this issue. All android devices give each file/picture a different name and is never a problem with multiple file/picture uploads.
Jun 13, 2016 01:40 PM|PatriceSc|LINK
I meant "by design on iOS".
Even on other platform you likely may have issues if you don't take into account that multiple users could use the same file name or that a single user could use the same name in multiple folders.
For now the simplest approach could be to check for file existance and to alter the name you'll use to save this file if needed (appending 1, 2, 3 etc.. to the file name until a file with this name is not found for example). Seems you are doing something
similar so do you have a remaining problem?
You have less control client side, and it would be surprising if for example you could alter
https://developer.mozilla.org/en-US/docs/Web/API/File/name before the upload etc...