HttpPostedFileBase uploadFile = Request.Files[file] as HttpPostedFileBase;
string fileN = uploadFile.FileName;//获取文件名称
if (fileN.IndexOf("\\") > 0) //如果有/ 说明是ie浏览器
{
fileN = fileN.Substring(fileN.LastIndexOf("\\") + 1, fileN.Length - fileN.LastIndexOf("\\") - 1);
}
fileN = DateTime.Now.ToString("yyyyMMddHHmmssffff") + Path.GetExtension(fileN);//设置文件名称
if (uploadFile != null && uploadFile.ContentLength > 0)
{
path = Path.Combine(pathForSaving, fileN);
uploadFile.SaveAs(path);
url += "/Upload/files/" + fileN;
int i = Request.Files.Count;
}
时间: 2024-10-22 20:13:05