uploadfy导入Excel内容到数据库中

aspx:
<script src="/Content/Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="/Content/Scripts/swfobject.js" type="text/javascript"></script>
<script src="/Content/Scripts/jquery.uploadify.v2.1.0.min.js" type="text/javascript"></script>
<link href="/Content/Styles/uploadify.css" rel="stylesheet" type="text/css" />


<div style="float:left; width:280px">
                <input type="file" name="uploadify" id="uploadify" />
                <p> &nbsp;
                <a charset="utf-8" href="javascript:startUpload()">开始上传</a> &nbsp;| &nbsp;
                <a charset="utf-8" href="javascript:cancelUpload()">取消上传</a>
                </p>
            </div>
            <div style=" width:100%; height:36px;">
                <div id="fileQueue" style="text-align:left;"></div>
            </div>
            <div style="width:100%;" id ="divImportP">
                <img src="/Content/images/large-loading.gif" alt="加载中.." style=" display:block; float:left; width:32px; height:32px;" />
                <div style="color:#999900; float:left; margin-left:4px">导入数据处理中,请稍侯,请勿关闭本对话框,完成后会自动关闭.</div>
            </div>




js:
var uploadSizeLimit = 30242880;


        $("#uploadify").uploadify({
            'uploader': '/Content/jquery/up/uploadify.swf',
            'script': 'DoImport',
            'scriptData': { uploadtype: 'selCustom', q_t: $("#txtCustom").text() },
            'cancelImg': '/Content/jquery/up/cancel.png',
            'folder': '',
            'sizeLimit': uploadSizeLimit,
            'queueID': 'fileQueue',
            'method ': 'POST',
            'auto': true,
            'multi': false,
            'fileExt': '*.xls;*.xlsx;',  //'*.*'表示所有类型的文件
            'fileDesc': '请选择Excel文件(*.xls,*.xlsx)',
            onSelect: function (event, queueID, fileObj) {
                var size = parseInt(fileObj.size);
                if (size > uploadSizeLimit) {
                    alert("对不起,文件大小超过限制(30M),请重新选择");
                    g_filesize = 0;
                    cancelUpload();
                    return false;
                }
                $('#divImportP').removeClass('Hide');
                $('#uploadify').uploadifySettings('scriptData', { uploadtype: 'CustomQR', q_t: $("#txtCustom").val() });
            },
            onError: function (event, queueId, fileObj, errorObj) {
                alert("上传失败: " + errorObj.info);
            },
            onCancel: function (event, queueId, fileObj, data) {
            },
            onComplete: function (event, queueId, fileObj, response, data) {
               
                var result = eval("(" + response + ")");
                if (result.result < 0) {
                    alert(result.data);
                } else {
                    alert("上传成功");
                }
            }
        });

function startUpload() {
    $('#uploadify').uploadifyUpload();
}

function cancelUpload() {
    $('#uploadify').uploadifyClearQueue();
}

你可能感兴趣的:(upload)