PDA

View Full Version : آپلود عکس



elmira_63
پنج شنبه 29 بهمن 1388, 11:51 صبح
سلام دوستان
من برای upload عکس از کد زیر استفاده میکنم



string path = Request.PhysicalApplicationPath;
path = path + "Images\\"+"temp_pic\\" + Session.SessionID + ".jpg";
FileUpload1.SaveAs(path);


تو سیستم خودم هیچ مشکلی نداره ولی روی هاست که میذارم این ارور رو میده



Server Error in '/' Application.

Access to the path 'C:\Inetpub\vhosts\karavaranjob.ir\httpdocs\Images \temp_pic\muh3402dijtjkb55lvwd5myn.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 'C:\Inetpub\vhosts\karavaranjob.ir\httpdocs\Images \temp_pic\muh3402dijtjkb55lvwd5myn.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) 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 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 'C:\Inetpub\vhosts\karavaranjob.ir\httpdocs\Images \temp_pic\muh3402dijtjkb55lvwd5myn.jpg' is denied.] System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +7714255 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) +1162 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +61 System.IO.FileStream..ctor(String path, FileMode mode) +55 System.Web.HttpPostedFile.SaveAs(String filename) +99 System.Web.UI.WebControls.FileUpload.SaveAs(String filename) +23 Admin_freetextbox_News.ImageButton4_Click(Object sender, ImageClickEventArgs e) +83 System.Web.UI.WebControls.ImageButton.OnClick(Imag eClickEventArgs e) +108 System.Web.UI.WebControls.ImageButton.RaisePostBac kEvent(String eventArgument) +118 System.Web.UI.WebControls.ImageButton.System.Web.U I.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3082

amir40200
پنج شنبه 29 بهمن 1388, 13:08 عصر
شما اجازه دسترسی write رو به فولدری که توش عکس ها رو آپلود میکنید ، دادید ؟

raziee
پنج شنبه 29 بهمن 1388, 15:41 عصر
شما بايد در كنترل پنل هاستتون به اون پوشه دسترسي بديد كه برنامه تون بتونه عكس رو بنويسه.
در ضمن اسم عكس ها رو تغيير بديد( به دليل مسائل امنيتي)