文件上传的图像验证(javascript) [英] image validation for file upload(javascript)

查看:83
本文介绍了文件上传的图像验证(javascript)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

heyy ...



我想验证文件上传时的图像(上传前)。我找到了一个java脚本....这里是javascript ...



heyy...

I want to validate the images on file upload(before upload) .I find a java script for this....here is the javascript ...

<script type="text/javascript">
    $(function() {
    $('#<%=fileupload1.ClientID %>').change(
        function()

         {
            var fileExtension = ['jpeg', 'jpg', 'png', 'gif', 'bmp'];
            if ($.inArray($(this).val().split('.').pop().toLowerCase(), fileExtension) == -1)
                               alert("Only '.jpeg','.jpg', '.png', '.gif', '.bmp' formats are allowed.");


        })
    })
</script>







但我希望我面对的问题是......,我有4个fileupload控件..所以每个我必须单独的javascript ..can这个javascript句柄在单个javascript .... ?? /




but want I face the problem is ..,I have 4 fileupload controls ..so for each I have to put separate javascript ..can this javascript handle in single javascript....??/

推荐答案

(函数(){


('#<% = fileupload1.ClientID %> ; ')。更改(
function()

{
var fileExtension = ['jpeg','jpg','png','gif', 'BMP'];
if(
('#<%=fileupload1.ClientID %>').change( function() { var fileExtension = ['jpeg', 'jpg', 'png', 'gif', 'bmp']; if (


.inArray(


这篇关于文件上传的图像验证(javascript)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆