经过楼上的提示,使用HttpHandler,已经可以上传文件了。第一步:但是楼上DEMO中的页面还不行,所以我修改了一下。
<script src="~/Scripts/jquery-ui.custom.js" type="text/javascript"></script>
<script id="scriptInit" type="text/javascript">
$(document).ready(function () {
var progressbar = $("#progressbar");
//Initializes the wijupload with file-input element.
var upload = $("#upload").wijupload({
totalUpload: function () {
progressbar.show();
},
//Hide the progress-bar when upload action finished.
totalComplete: function () {
progressbar.fadeOut(1500, function () {
if (supportXhr) {
$("#progressbar").wijprogressbar("option", "value", 0);
}
});
},
//Get the total progress of wijupload and update the progress-bar.
totalProgress: function (e, data) {
if (supportXhr) {
$("#progressbar").wijprogressbar("option", "maxValue", data.total);
$("#progressbar").wijprogressbar("option", "value", data.loaded);
}
},
action: "C1Upload.ashx"
});
supportXhr = $("#upload").wijupload("supportXhr");
if (supportXhr) {
progressbar.wijprogressbar({ value: 0 });
}
progressbar.hide();
});
</script>
<style>
#progressbar-container {
height: 5em;
}
form {
width: 800px;
}
</style>
<form action="/CardProduce/UploadFiles" runat="server" enctype="multipart/form-data" id="form1" name="form1">
<input id="upload" type="file" multiple name="upload"/>
<div id="progressbar-container">
<div id="progressbar"></div>
</div>
</form>
第二步:做了一个C1Upload.ashx,代码和楼上Demo中一致,仅仅是在C1Upload.ashx中设置了上传文件夹。
第三部:在web.config中注册,<add path="C1Upload.ashx" verb="*" type="工程名.C1Upload,工程名" validate="false" />
本人还有些许问题,就是如何将按钮中的英文Upload Files, Upload All和Upload Cancel修改为中文呢? |