各位高手,为什么我做的上传代码,再上传大文件时(如:1M)总是过不去,也不报任何错误,但是小文件可以(如:40K)。我用的tomcat323,现象是没有任何错误,IE一直处于好象是连接状态。 你用的是jspSmartUpload吗?如果是,用其自带的Sample2的方法可以upload大文件,Sample1的方法不行。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我这里有一个程序,原来也是不能够上传大文件,后来改了WEB.CONFIG就可以了,我用的是UpLoadFile,我把上传流和下载做到一块方便调试而已 private void upLoadButton_Click(object sender, System.EventArgs e) { string upLoadFileName;// string upLoadFilePath;// string upLoadFileToDir;// upLoadFileToDir="D:\\UpLoad_Files\\"; //返回的是通过文件对话框选择的文件名,这之中包含了文件的目录信息 upLoadFileName=upLoadFile.PostedFile.FileName; //去掉目录信息,返回文件名称 upLoadFileName=Path.GetFileName(upLoadFileName);// if (!Directory.Exists(upLoadFileToDir))// // //如果目录不存在,则创建一个// Directory.CreateDirectory(upLoadFileToDir);// // //得到上传目录及文件名称// upLoadFilePath=upLoadFileToDir+upLoadFileName; //获得并显示上传文件的属性 if (upLoadFile.PostedFile.ContentLength > 4194304) { string strShut; strShut = "<Script language=javascript>\r\n alert('"; strShut = strShut+"文件不得大于4M"; strShut = strShut+"')\r\n </Script>\r\n"; Page.RegisterStartupScript("strShut",strShut); exit sub; } else {// upLoadFile.PostedFile.SaveAs(upLoadFilePath); } //获得文件名称 fileNameLabel.Text=upLoadFileName; //获得文件类型 fileTypeLabel.Text=upLoadFile.PostedFile.ContentType; //获得文件长度 fileTypeLabel.Text=upLoadFile.PostedFile.ContentLength.ToString(); RequiredFieldValidator1.Text="恭喜您,上传文件成功!"; //将文件存为数据库字节流 byte[] fsData = new byte[upLoadFile.PostedFile.InputStream.Length]; upLoadFile.PostedFile.InputStream.Read (fsData,0,(int)upLoadFile.PostedFile.InputStream.Length ); upLoadFile.Dispose (); //在服务器生成附件// string cc="d:\\"+fileNameLabel.Text;// FileStream fout = new FileStream (cc,FileMode.OpenOrCreate ,FileAccess.Write ); //将数据库字节流写入客户端文件 Response.AppendHeader("Content-Disposition","attachment; filename="+Server.UrlEncode (fileNameLabel.Text)); Response.BinaryWrite(fsData); Response.End();web.config 添加如下说明<httpRuntime maxRequestLength="xxxx" useFullyQualifiedRedirectUrl="true" executionTimeout="45" />xxxx是你要限制的上传文件大小 好像需要该webconfig文件中的一些参数:<system.web> <httpRuntime maxRequestLength="1000000000" useFullyQualifiedRedirectUrl="true" executionTimeout="145"/>后面添全就行了,第一行就是限制大小的 tomcat??目前.net可以运行在tomcat上吗? ???目前.net可以运行在tomcat上吗?? ???目前.net可以运行在tomcat上吗?? .net中怎样实现打印收据单,从数据库提出的数据,自己安排文字在单子上的位置 asp.net中如何判断一条记录在一张表中 aspx和html asp.net的用户管理,注册时添加额外信息带来的数据profile表冗余 为什么啊?难道是人品问题. 关于宽度的问题 http 500 错误怎么解决啊 asp.net网站如何实现所有栏目动态你添加? DataGrid中一列能否同时帮定数据源的两列? 有誰能帮我搞定把一个数据库国連接字符串定在一个自定义类中供所有页面调用 高分求救!如何防止用户点击“刷新”、“后退”带来的影响??? 又来送分了:如何防止别人在没有通过登录就进入你的受保护的页面?
{
string upLoadFileName;
// string upLoadFilePath;
// string upLoadFileToDir;// upLoadFileToDir="D:\\UpLoad_Files\\";
//返回的是通过文件对话框选择的文件名,这之中包含了文件的目录信息
upLoadFileName=upLoadFile.PostedFile.FileName;
//去掉目录信息,返回文件名称
upLoadFileName=Path.GetFileName(upLoadFileName);// if (!Directory.Exists(upLoadFileToDir))
//
// //如果目录不存在,则创建一个
// Directory.CreateDirectory(upLoadFileToDir);
//
// //得到上传目录及文件名称
// upLoadFilePath=upLoadFileToDir+upLoadFileName;
//获得并显示上传文件的属性
if (upLoadFile.PostedFile.ContentLength > 4194304)
{
string strShut;
strShut = "<Script language=javascript>\r\n alert('";
strShut = strShut+"文件不得大于4M";
strShut = strShut+"')\r\n </Script>\r\n";
Page.RegisterStartupScript("strShut",strShut);
exit sub;
}
else
{
// upLoadFile.PostedFile.SaveAs(upLoadFilePath);
}
//获得文件名称
fileNameLabel.Text=upLoadFileName; //获得文件类型
fileTypeLabel.Text=upLoadFile.PostedFile.ContentType; //获得文件长度
fileTypeLabel.Text=upLoadFile.PostedFile.ContentLength.ToString(); RequiredFieldValidator1.Text="恭喜您,上传文件成功!";
//将文件存为数据库字节流
byte[] fsData = new byte[upLoadFile.PostedFile.InputStream.Length];
upLoadFile.PostedFile.InputStream.Read (fsData,0,(int)upLoadFile.PostedFile.InputStream.Length );
upLoadFile.Dispose ();
//在服务器生成附件
// string cc="d:\\"+fileNameLabel.Text;
// FileStream fout = new FileStream (cc,FileMode.OpenOrCreate ,FileAccess.Write );
//将数据库字节流写入客户端文件
Response.AppendHeader("Content-Disposition","attachment; filename="+Server.UrlEncode (fileNameLabel.Text));
Response.BinaryWrite(fsData);
Response.End();web.config 添加如下说明
<httpRuntime maxRequestLength="xxxx"
useFullyQualifiedRedirectUrl="true"
executionTimeout="45"
/>
xxxx是你要限制的上传文件大小
<system.web>
<httpRuntime maxRequestLength="1000000000" useFullyQualifiedRedirectUrl="true" executionTimeout="145"/>
后面添全就行了,第一行就是限制大小的
目前.net可以运行在tomcat上吗?
目前.net可以运行在tomcat上吗??
目前.net可以运行在tomcat上吗??