62,025
社区成员
发帖
与我相关
我的任务
分享
$(function() {
$("#FileUpload").bind("change", function() {
//开始提交
$("#form1").ajaxSubmit({
beforeSubmit: function(formData, jqForm, options){
$(".files").hide();
$(".uploading").show();
},
success: function(data, textStatus) {
if (data.msg == 1) {
$("#txtImgUrl").val(data.msbox);
} else {
alert(data.msbox);
}
$(".files").show();
$(".uploading").hide();
},
error: function(data, status, e) {
alert("上传失败,错误信息:" + e);
$(".files").show();
$(".uploading").hide();
},
url: "/Data/Ajax/Upload.ashx",
type: "post",
dataType: "json",
timeout: 600000
});
});
});
public class Upload : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
HttpPostedFile _upfile = context.Request.Files["FileUpload"];
string _delfile = context.Request.Params["txtImgUrl"];
if (_upfile == null)
{
context.Response.Write("{\"msg\": 0, \"msbox\": \"请选择要上传文件!\"}");
return;
}
UpLoad upFiles = new UpLoad();
string msg = upFiles.fileSaveAs(_upfile, 0);
//返回成功信息
context.Response.Write(msg);
}
public bool IsReusable
{
get
{
return false;
}
}
}
<httpRuntime executionTimeout="600" maxRequestLength="2097151" requestValidationMode="2.0" />
webconfig试试这个呢?