开发者

upload pictures

开发者 https://www.devze.com 2023-02-05 03:43 出处:网络
Hello everyone i have a problem with my website. When i upload pics using my local host, it works fine but when i try to upload the pics from the internet, i have the following error message:

Hello everyone i have a problem with my website. When i upload pics using my local host, it works fine but when i try to upload the pics from the internet, i have the following error message:

Server Error in '/please-god' Application.

Access to the path 'D:\Hosting\4423045\html\please-god\UploadedImages\3.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:\Hosting\4423045\html\please-god\UploadedImages\3.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 , 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:

Line 21:             If imageUpload.HasFile Then
Line 22:                 Dim baseDirectory As String = Server.MapPath("~/UploadedImages/")
Line 23:                 imageUpload.SaveAs(baseDirectory & pictureIDJustAdded & ".jpg")
Line 24:             End If
Line 25:         End If

Source File: D:\Hosting\4423045\html\please-god\PhotoAdmin\Default.aspx.vb Line: 23

Stack Trace:

[UnauthorizedAccessException: Access to the path 'D:\Hosting\4423045\html\please-god\UploadedImages\3.jpg' is denied.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +7715167
   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
   PhotoAdmin_Default.dvPictureInsert_ItemInserted(Object sender, DetailsViewInsertedEventArgs e) in D:\Hosting\4423045\html\please-god\PhotoAdmin\Default.aspx.vb:23
   System.Web.UI.WebControls.DetailsView.OnItemInserted(DetailsViewInsertedEventArgs e) +108
   System.Web.UI.WebControls.DetailsView.HandleInsertCallback(Int32 affectedRows, Exception ex) +69
   System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +134
   System.Web.UI.WebControls.DetailsView.HandleInsert(String commandArg, Boolean causesValidation) +274
   System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +676
   System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +95
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.DetailsViewRow.OnBubble开发者_开发技巧Event(Object source, EventArgs e) +113
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118
   System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
   System.Web.UI.WebControls.LinkButton.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) +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


You need to give permissions to the IIS user to that directory. The error message provides information on what to do, but there is more info below

More info here - http://www.webdeveloper.com/forum/showthread.php?t=131624

or

https://stackoverflow.com/search?q=Exception+Details%3A+System.UnauthorizedAccessException

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号