//z引用
using System.IO;
using System.Data.SqlClient;
//下载
DataSet ds = j.GetDownDetails(downloadID);
string filename = "../Admin/download/" + ds.Tables[0].Rows[0][3].ToString() + "";
FileInfo DownloadFile = new FileInfo(Server.MapPath(filename));
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(DownloadFile.Name, System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
//上传
//调用
if (FileUpload1.FileName != String.Empty)
{
ig.ImgUrl = UploadIMG(out msg, FileUpload1);//上传的文件
}
protected byte[] UploadIMG(out String message, FileUpload fuControl)
{
message = String.Empty;
try
{
if (!fuControl.HasFile)
{
//未包含文件
}
String fileContentType = fuControl.PostedFile.ContentType;
if (!(fileContentType == "image/x-png" || fileContentType == "image/bmp" || fileContentType == "image/gif" || fileContentType == "image/pjpeg" || fileContentType == "image/jpeg"))
{
//所上传文件不是已知的图片类型 }
return fuControl.FileBytes;
}
catch (Exception exp)
{
}
}