C#uploadify只上传图

来源:互联网 发布:java怎么做需求分析 编辑:程序博客网 时间:2024/05/05 11:11
    $(document).ready(function () {        $('#AvgFile').uploadify({            'uploader': '@Url.Content("~/Scripts/uploadify.swf")',            'script': '@Url.Action("uploadify", "pccommon")' + "?t=" + Math.random(),            'cancelImg': '@Url.Content("~/Scripts/cancel.png")',            'buttonImg': '@Url.Content("~/Scripts/uploadbtn.gif")',            'fileExt': '*.jpg;*.png;*.jpeg',            'fileDesc': '请选择jpg png jpeg文件',            'auto': true,            'removeCompleted': false,            'onComplete': function (event, ID, fileObj, response, data) {                deletefile("#Avg");                if (response != "" && response != "\"\"") {                    if (fileObj.type == '.jpg' || fileObj.type == '.png' || fileObj.type == '.jpeg') {                        $("#Avg").val(response);                        $("#Avg").valid();                        alert("上传完毕!");                        $("#AvgErr").hide();                    }                    else {                        $("#Avg").val(response);                        deletefile("#Avg");                        $('#AvgFile').uploadifyCancel(ID);                        alert(fileObj.name + "-文件格式不符合要求");                                                return false;                    }                } else {                    alert("上传失败!");                }            },            'onCancel': function (event, ID, fileObj, data) {                deletefile("#Avg");                $("#Avg").val("");            },            'sizeLimit': 2097152        });    });    function deletefile(id) {        var filename = $(id).val();        var url = '@Url.Action("deletefile", "pccommon")';        $.get(url, { filename: filename });    }    function uploadfile(id) {        $(id).uploadifyUpload();    }


0 0
原创粉丝点击