New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added possibility to rename the filename before uploading #955
Conversation
How does Renaming work. |
How can i rename the file before uploading? There is any example of this. Thanks |
please merge 👍 👍 👍 |
Example on how to use added. |
yep, please merge! |
@enyo is there something I can do? |
+1 my vote for merging |
Added possibility to rename the filename before uploading
Great work. Thanks |
Thank you for adding this functionality. But when I use an event listener like |
I can comfirm what demircancelebi told us. @ demircancelebi |
The problem is that you can not change the file in javascript. It's not allowed for security reason. So the trick here with the renameFilename is, that we upload another filename as the original. The original filename never gets touched. See: https://developer.mozilla.org/en-US/docs/Web/API/File/name |
Thank you for the fast response. I am trying to identify those images by name. But it won't work if you upload two different pictures with the same name. At the moment, I have this mapping in my Javascript code: |
I think we could store a "renamed" name as another property in a _renameFilename: (name, file) =>
if typeof @options.renameFilename is "function"
name = @options.renameFilename(name, file)
file.newname = name With such change, new file name will be accessible for all methods, and also I passed |
Is there any progress on this? Is it possible to access new name inside If this can't be done using Dropzone APIs then I may end up using something like below: I wish there is easy way to access new file name. |
The renamefile is not working on my side. I did exactly the same implementation as you have. |
I'm using this rename function, because I upload the images first to a temporary directory. To prevent double filenames, I rename the file with an unique I before uploading the file. But, this is failing because the function referring to in options.renameFilename is called twice for one file. So the first time it generates unique string based on random numbers. This new name is used in the frontend to show in the dropzone. But when uploading the actual file, the function is requested again and a new unique string is generated. So I can never match the two files again. I think that it should just call this function once and maintain the generated name. |
renameFilename is changed name of file in frontEnd but in backend still file object name is used |
From what I see, the best way to approach this, would be to invoke @priyapanigrahy this seems a bit strange to me, since the new name is attached as a form field, so I don't see how that would happen. Are you using the latest version? |
This is now implemented in
|
Help me deal with "renameFile".
|
Please help!!!!!!! |
I tried to use
but unfortunately dropzone sent 2 data to upload.php. One of them was with original file name and the other one was myFileName. On server side I got 2 files and when I tried to delete it from dropzone, it deleted the file that has the original name. I think there is something wrong with renameFilename function. It should send one data with changed name. Does anyone have a solution? |
A loot of people need to rename the filename before it's uploaded, myself included. So I quickly implemented the functionality.
See #656 or #722
Example how to use: (if the options.renameFilename is not specified, nothing changes)