开发者

How to restrict file types for a user in a web browser

Hi i have a question that is almost like other questions but with a small but very important difference.

How can i restric开发者_运维技巧t file types for user with a popup showed in the browser.

  • The standard file input of html can limit that with a command but it does not work in all browser so it is not an option.

  • I do not want to validate the file extension after the user has chosen a file but before that, when he is choosing.

  • Founded this http://demo.swfupload.org/v220/index.htm, but it uploads the file after the user has chosen it, i do not want to do that, i want to upload it after the user submits the form.

So the problem looks like this that there are some ways of not letting the user send a not valid file but they are not good because, one is that i validate after the user have chosen the file and the other is that i upload the file before the user submits the form.

I just want a simple thing to not letting to "chose" a not valid file, it does not matter if it will be made with java script or flash, just let it work.

maybe you have some ideas on how to do it because i searched the whole internet and did not found any solution.


Uploadify supports that feature and is very customizable. You should have no problems setting it up in a way that it uploads the file when the user submits.


you can put a condition on the action file of php where all the fields get by submit the page.at that time you can put validation for the file type. if the file type is not as you mentioned then redirect the error message and let user to make try again.

Thanks.


<input type="file" accept="text/html,image/jpeg">

Also: Mozilla`s doc


Not sure if that's what you're after, but Flash FileReference.browse() method has a FileFilter structure as an input argument, and there you can limit the types of files that the upload dialogue will show.

flash.net.FileReference

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜