上传小文件没问题 上传大于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 值 求解
/// 原来这个项目中用了这个控件 所以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>
upload控件只能上传4M的,即使config里面设置了也是没用的。
实现大文件上传可以使用Jquery来实现,可以参考文章
http://www.cnblogs.com/waw/archive/2011/09/01/2162773.html
希望对你有用
你修改一下这里:把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>
也有可能超时错误的!