上传:
1、上传文件先保存到服务器 File.SaveAs(path)
2、sql(文件和sql在一个服务器上)进行保存操作:
insert into File(filename,filebody)
values('长大了是否.txt',(SELECT * FROM OPENROWSET(BULK '" + path + "',SINGLE_BLOB) AS x))
下载:
if (reader.Read())
Response.Clear();
String strFileName = reader["oldname"].ToString();
Response.ContentType = "APPLICATION/OCTET-STREAM";
Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(strFileName));
Response.Buffer = true;
Response.BinaryWrite((byte[])reader["filecontent"]);