مرجع تخصصی برنامه نویسان

انجمن تخصصی برنامه نویسان فارسی زبان

کاربر سایت

محسن اشکبوس

عضویت از 1392/08/17

مشکل آپلود تصویر بر روی هاست از طریق fileupload

  • دوشنبه 16 شهریور 1394
  • 01:12
تشکر میکنم

کد آپلود تصویراین است : 

string filename = FileUpload1.PostedFile.FileName;
                filename = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
                FileUpload1.PostedFile.SaveAs(Server.MapPath("/Resources/Images/" + filename));

و خطایی که میدهد : 

Access to the path 'D:\vhosts\timestudy.ir\Shop.timestudy.ir\Resources\Images\personal.jpg' is denied.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.UnauthorizedAccessException: Access to the path 'D:\vhosts\timestudy.ir\Shop.timestudy.ir\Resources\Images\personal.jpg' is denied. 

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. 

To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[UnauthorizedAccessException: Access to the path 'D:\vhosts\timestudy.ir\Shop.timestudy.ir\Resources\Images\personal.jpg' is denied.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +217
   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) +1305
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +60
   System.IO.FileStream..ctor(String path, FileMode mode) +55
   System.Web.HttpPostedFile.SaveAs(String filename) +94
   Forms_Shop_ChangeProfile.btnUpload_ServerClick(Object sender, EventArgs e) +185
   System.Web.UI.HtmlControls.HtmlButton.OnServerClick(EventArgs e) +116
   System.Web.UI.HtmlControls.HtmlButton.RaisePostBackEvent(String eventArgument) +101
   System.Web.UI.HtmlControls.HtmlButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9528578
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408

 

پاسخ های این پرسش

تعداد پاسخ ها : 2 پاسخ
کاربر سایت

ایمان مدائنی

عضویت از 1392/01/20

  • سه شنبه 17 شهریور 1394
  • 08:48
کاربر سایت

محسن اشکبوس

عضویت از 1392/08/17

  • سه شنبه 17 شهریور 1394
  • 15:18

با تشکر از پاسخ شما ولی مشکل بنده این نبود.مشکل از عدم دسترسی بر روی هاست بود که با دادن دسترسی بر روی پوشه مورد نظر حلش کردم.باز هم از پاسختون تشکر میکنم

کاربرانی که از این پست تشکر کرده اند

هیچ کاربری تا کنون از این پست تشکر نکرده است

اگر نیاز به یک مشاور در زمینه طراحی سایت ، برنامه نویسی و بازاریابی الکترونیکی دارید

با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)