长文件名和中文文件名的文件为什么不能下载---等三个问题(300分谢诸大侠)
关于文件下载,我有两个问题:
1、上传文件(含路径文件全名变量:upfile)时,我想将upfile.ContentType存入sql数据库,但是好象编码问题,如upfile.ContentType="application/msword"
其中有"/",如何解决这个问题?
2、文件下载时,对于中文和长文件名的文件,则提示无法找到路径及打开页面。
3、另有如70M左右的文件上传没法成功。我已经在web.config中加入了:
<httpRuntime
executionTimeout="900"
maxRequestLength="819200"
useFullyQualifiedRedirectUrl="false"
/>
附:我的下载代码为:
strFileName=文件存放的物理路径的带扩展名的文件名(经Server.MapPath()转换过的)
FileStream fs = new FileStream(strFileName, FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
Label2.Text=strFileName;
Response.Clear();
Response.ClearHeaders();
Response.ContentType = "application/octet-stream";
strFileName = HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(strFileName));
Label1.Text=strFileName;
Response.AppendHeader("Content-Disposition", "attachment; filename="+strFileName);
Response.BinaryWrite(bytes);
Response.End();