最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

rename file that user uploads javascript - Stack Overflow

programmeradmin4浏览0评论

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?

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?

Share Improve this question edited May 15, 2013 at 15:52 Alberto Zaccagni 31.6k11 gold badges75 silver badges107 bronze badges asked May 15, 2013 at 15:50 user1571352user1571352 1391 gold badge1 silver badge7 bronze badges 4
  • 5 rename the file after it uploads on the server? – Amitd Commented May 15, 2013 at 15:52
  • 1 you cannot deal with file to be uploaded with js what so ever – Muhammad Bekette Commented May 15, 2013 at 15:52
  • 1 You need to do it at the server level. – epascarello Commented May 15, 2013 at 15:53
  • if u are using php for the server side language u want somthing like php.net/manual/en/function.rename.php functions – underscore Commented May 15, 2013 at 15:55
Add a comment  | 

3 Answers 3

Reset to default 14

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.

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.

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

发布评论

评论列表(0)

  1. 暂无评论