I'd like for my users to be able to re-name a file before uploading it.
I have a File
object in Javascript which has a name
property that is already set, but i'd like for this to be able to be updated. Right now doing the obvious myFile.name = "new-name.txt"
returns an error that this property is read only.
What's the best way of changing the name
property on a JavaScript File
object?
You can add an
input
tag with the name on it and hide thename
property from the user. On the server, just use theinput
as the name and ignore the default name.