rename file that user uploads javascript

2019-01-25 08:05发布

I have the following html on a form:

<input type="file" name="uploadField" />

When users click on the browse button they can select any file but I want to rename the file using the value of another field on the form

I have a submit button. Can I do it here?

3条回答
欢心
2楼-- · 2019-01-25 08:12

for security reasons you cannot do such thing i.e. manipulate multipart file or file to be uploaded do that on server

查看更多
神经病院院长
3楼-- · 2019-01-25 08:16

Can I do it here?

No, for security reasons you have no control of this on the client. You can rename the file on the server when it gets uploaded.

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-01-25 08:21

I know the question is old but if anyone is still struggling with similar problem, please try to use append() or set() method of the FormData.

查看更多
登录 后发表回答