上傳代碼:
string fullname = FileUpload1.FileName.ToString();
string url = FileUpload1.PostedFile.FileName.ToString();
string typ = FileUpload1.PostedFile.ContentType.ToString();
string typ2 = fullname.Substring(fullname.LastIndexOf(".")+ 1);
int size = FileUpload1.PostedFile.ContentLength;
string upload_file = Server.MapPath("./upload/") + Resumeid + "/" + fullname;
try
{
FileUpload1.PostedFile.SaveAs(upload_file);
}
catch
{
//error message
}
下載代碼:
if (File.Exists(filePath))
{
FileInfo file = new FileInfo(filePath);
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解決中文亂碼
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename.ToString().Trim()); //解決中文文件名亂碼
Response.AddHeader("Content-length", file.Length.ToString());
Response.ContentType = "appliction/octet-stream";
Response.WriteFile(file.FullName);
Response.End();
}
創(chuàng)建新文件夾代碼:
string CreatePath = Server.MapPath("./upload/") + folder_name.toString();
if (!Directory.Exists(CreatePath))
{
Directory.CreateDirectory(CreatePath);
}
本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。