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>  
<a charset="utf-8" href="javascript:startUpload()">开始上传</a>  |  
<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();
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值