![]() |
1
22
检查它的
在jquery中(因为您的标签提到它):
或者在普通的javascript中:
|
![]() |
2
17
我的函数将检查用户是否选择了该文件,您还可以检查是否允许该文件扩展名。 试试这个: <input type="file" name="fileUpload" onchange="validate_fileupload(this.value);"> function validate_fileupload(fileName) { var allowed_extensions = new Array("jpg","png","gif"); var file_extension = fileName.split('.').pop().toLowerCase(); // split function will split the filename by dot(.), and pop function will pop the last element from the array which will give you the extension as well. If there will be no extension then it will return the filename. for(var i = 0; i <= allowed_extensions.length; i++) { if(allowed_extensions[i]==file_extension) { return true; // valid file extension } } return false; } |
![]() |
3
1
基于Ravinders解决方案,此代码停止提交表单。在服务器端检查扩展也是明智的。所以你不会让黑客上传他们想要的任何东西。
|
![]() |
4
0
至少在firefox中,dom检查器告诉我文件输入元素有一个名为
|
![]() |
5
0
我是从某个论坛上得到的。希望对你有用。
|
|
Newbie_Coder · 如何使用Jquery无画布裁剪框架 1 年前 |
|
NovoMannen · 导航中的下拉菜单在内容后面重叠 1 年前 |
![]() |
Community wiki · 无法从jquery文档调用函数 2 年前 |