更新时间:2023-09-13 14:57:10
Actually, it's fairly obvious:string relativePath = "~/Uploads"; string absolutePath = Server.MapPath(relativePath); string fileName = fuImage.FileName; string fullFilePath = string.Format("{0}/{1}",absolutePath,relativePath); fuImage.SaveAs(fullFilePath);
Why?
Assume your website root folder is "C:\Websites\Gharuboy".
SorelativePath = "~/Uploads" absolutePath = "C:\Websites\Gharuboy\Uploads" fullFilePath = "C:\Websites\Gharuboy\Uploads/~/Uploads"And
fuImage.SaveAs(fullFilePath);Will try to save as that file...
No. I think what you want is this:string fullFilePath = string.Format("{0}/{1}",absolutePath,fileName);