我有一个 asp.net 项目,我正在将选定的图像保存到 NewUrunler1 文件中,并将图像的路径保存在我的数据库中。在本地,它可以正常工作,但是由于我将项目移动到了我的 Godaddy 主机,因此保存方法会出错。这是我保存图像的代码:
protected void UploadImage()
{
try
{
HttpPostedFile yuklenecekDosya = FileUploadImage.PostedFile;
if (yuklenecekDosya != null)
{
FileInfo dosyaBilgisi = new FileInfo(yuklenecekDosya.FileName);
string yuklemeYeri = Server.MapPath("~/Images/NewUrunler1/" + dosyaBilgisi);
FileUploadImage.SaveAs(Path.Combine(yuklemeYeri));
}
}
catch (Exception e)
{
failDiv.Visible = true;
lblHata.Text = e.ToString();
}
}
当我运行它时,我从 try catch 中得到一个错误。这是错误:
System.UnauthorizedAccessException: Access to the path 'G:\PleskVhosts\ada-crm.com\httpdocs\Images\NewUrunler1\deneme.png' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at CRM.UrunEkle.UploadImage()
我是 asp.net 的新手,很抱歉,如果这是一个简单的问题,但我在网上搜索并无法解决。感谢您的时间。