private string upfile()
{
try
{
String time = DateTime.Now.ToString();
time = time.Replace("-", "");
time = time.Replace(" ", "");
time = time.Replace(":", "");
time = time.Replace("/", "");
//获取上传文件名
String fileName = this.FileUpload1.PostedFile.FileName;
//命名新文件
string str = fileName.Substring(fileName.LastIndexOf('.'), fileName.Length - fileName.LastIndexOf('.'));
fileName = time + str;
fileName = fileName.Substring(fileName.LastIndexOf("//") + 1);
string filePath = Server.MapPath("~/") + "Admin//UpLoadPic//";
FileUpload1.PostedFile.SaveAs(filePath + fileName);
return fileName;
}
catch (Exception e)
{
return null;
}
}
上传图片到文件夹的方法
最新推荐文章于 2021-08-06 06:57:43 发布