上傳:
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"]);