导入
if (this.FILEUP.PostedFile.FileName.Length <= 0) return;
Stream stream;
string Path = FILEUP.PostedFile.FileName;// 文件名称
int Size = FILEUP.PostedFile.ContentLength; // 文件大小
string Type = FILEUP.PostedFile.ContentType; // 文件类型
stream = FILEUP.PostedFile.InputStream;
byte[] Content = new byte[Size];
int Status = stream.Read(Content, 0, Size);
//导出
byte[] bytes = (byte[])ds.Tables[0].Rows[0]["files"];
Response.Clear();
Response.Buffer = false;
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
//设置读取的文件头 ;并将中文文件头转码
Response.AddHeader("Content-Disposition", "attachment; filename="
+ HttpUtility.UrlEncode(ds.Tables[0].Rows[0["name"].ToString()));
Response.AddHeader("Content-Length", bytes.Length.ToString());
//设置输出类型 这里可以保存在数据库中 动态实现类型
Response.ContentType = ds.Tables[0].Rows[0]["types"].ToString();
//输出
Response.OutputStream.Write(bytes, 0, bytes.Length);