首页 新闻 会员 周边

mvc1 uploadify 上传大文件 httperror 错误

0
悬赏园豆:50 [待解决问题]

上传小文件没问题 上传大于4M 报 httperror 错误 配置文件已经设置 

<script type="text/javascript">
$(function() {
$("#uploadify").uploadify({
'uploader': '/Content/Uploader/uploadify.swf',
'script': '/Mail/UploadAttachment',
'cancelImg': '/Content/Uploader/cancel.png',
'sizeLimit': 10240000000,
'simUploadLimit': 3,
'queueSizeLimit': 5,
'queueID': 'fileQueue',
'auto': false,
'multi': true,
'onComplete': function(event, queueId, fileObj, response, data) {
if (response != "") {
showInfo("成功上传" + response, true);
}
else {
showInfo("文件上传出错!", false);
}
},
'onError': function(event, queueID, fileObj, errorObj) {
alert(errorObj.info);
}
});
})

</script>

///后台方法如下

[AcceptVerbs(HttpVerbs.Post)]
public ContentResult UploadAttachment(HttpPostedFileBase FileData)
{
string fileType = Path.GetExtension(FileData.FileName);
string uploadPath = Path.Combine(MailConfiguration.MailFiles, @"UploadFile\");
string result = "";
if (null != FileData)
{
try
{
if (!Directory.Exists(uploadPath))
{
Directory.CreateDirectory(uploadPath);
}
FileData.SaveAs(uploadPath + FileData.FileName);
}
catch
{
result = "";
}
}
return Content(result);

}

/// 上传大文件时 HttpPostedFileBase 为null 值 求解

码仔的主页 码仔 | 初学一级 | 园豆:105
提问于:2012-07-20 15:15
< >
分享
所有回答(4)
0

/// 原来这个项目中用了这个控件 所以config设置文件大小没有 现在可以了

<location path="MailWrite.aspx" >
<!--上传文件的页面路径-->
<system.web>
<neatUpload useHttpModule="true" />
<!--为true则代表使用neatUpload的httpModule,false为不使用-->
<httpRuntime maxRequestLength="40960" executionTimeout="3600" useFullyQualifiedRedirectUrl="true" />
<!--允许最大为40M-->
</system.web>
</location>

码仔 | 园豆:105 (初学一级) | 2012-07-20 16:36
0

upload控件只能上传4M的,即使config里面设置了也是没用的。
实现大文件上传可以使用Jquery来实现,可以参考文章
http://www.cnblogs.com/waw/archive/2011/09/01/2162773.html

希望对你有用

CrazyJinn | 园豆:799 (小虾三级) | 2012-07-20 17:52
0

你修改一下这里:把sizeLimit: 10240000000去掉试试..

 1 <script type="text/javascript">
 2 $(function() {
 3 $("#uploadify").uploadify({
 4 'uploader': '/Content/Uploader/uploadify.swf',
 5 'script': '/Mail/UploadAttachment',
 6 'cancelImg': '/Content/Uploader/cancel.png',
 7 'sizeLimit': 10240000000,
 8 'simUploadLimit': 3,
 9 'queueSizeLimit': 5,
10 'queueID': 'fileQueue',
11 'auto': false,
12 'multi': true,
13 'onComplete': function(event, queueId, fileObj, response, data) {
14 if (response != "") {
15 showInfo("成功上传" + response, true); 
16 }
17 else {
18 showInfo("文件上传出错!", false);
19 }
20 },
21 'onError': function(event, queueID, fileObj, errorObj) {
22 alert(errorObj.info);
23 }
24 });
25 })
26 </script>
Hongten | 园豆:1768 (小虾三级) | 2012-07-20 20:49
0

也有可能超时错误的!

Tom.汤 | 园豆:3028 (老鸟四级) | 2012-07-23 12:33
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册