jQuery的文件上传内容类型/扩展验证 [英] jQuery-File-Upload content type/extension validation
问题描述
有没有办法做到这一点?
因为我会在server-sid用Paperclip来验证它,但是我认为最好在客户端验证一次。 b $ b
acceptFileTypes
允许的文件类型的正则表达式,文件名,因为只有支持File API的浏览器报告文件类型。
$ p $
类型:正则表达式
示例: /(\.|\/)(gif|jpe?g|png)$/i
请参阅 https://github.com/blueimp/jQuery-File-Upload/wiki /选项
I am using jQuery-File-Upload with rails 3, it works very well. But I didn't find anything about how to validate the extension or the content type of the upload file on the client-side.
Is there a way to do that?
Of cause I will anyway validate it by Paperclip at server-sid, but I think it would be better to validate it once at client-side.
acceptFileTypes
The regular expression for allowed file types, matches against either file type or file name as only browsers with support for the File API report the file type.
Type: Regular Expression
Example: /(\.|\/)(gif|jpe?g|png)$/i
See https://github.com/blueimp/jQuery-File-Upload/wiki/Options
这篇关于jQuery的文件上传内容类型/扩展验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!