将图像上传到我服务器中的文件夹时出错 [英] Error uploading image to the folder in my server

查看:86
本文介绍了将图像上传到我服务器中的文件夹时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 ASP.NET无权访问所请求的资源。考虑将资源的访问权限授予ASP.NET请求标识。 ASP.NET具有基本进程标识(在IIS 5上通常为{MACHINE} \ ASPNET或在IIS 6上为网络服务),如果应用程序未模拟,则使用该标识。如果应用程序通过<   identity     impersonate   =  true  /  > ,标识将是匿名用户(通常为IUSR_MACHINENAME)或经过身份验证的请求用户。 

要授予对文件的ASP.NET访问权限,请在资源管理器中右键单击该文件,选择属性,然后选择安全选项卡。单击添加以添加适当的用户或组。突出显示ASP.NET帐户,并选中所需访问的框。

来源错误:


第230行://字符串文件名= Path.GetFileName(pimageupload.FileName);
第231行:Utils.ImagePathSave =Images /+ filename1;
第232行:pimageupload.SaveAs(Server.MapPath(Utils.ImagePathSave));
第233行:// lblSt1.Text =在服务器上成功上传;
第234行://}

解决方案

错误实际上是告诉你需要做什么。您需要向运行代码的帐户授予权限。该帐户需要您尝试保存图像的文件夹的权限。



这取决于您的web.config设置和IIS是什么帐户。

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:


Line 230:        //            string filename = Path.GetFileName(pimageupload.FileName);
Line 231:        Utils.ImagePathSave = "Images/" + filename1;
Line 232:        pimageupload.SaveAs(Server.MapPath(Utils.ImagePathSave));
Line 233:        //            lblSt1.Text = "successfully uploded in server";
Line 234:        //        }

解决方案

The error is actually telling you what you need to do. You need to grant permissions to the account that is running the code. That account needs permissions to the folder where you are trying to save the image.

It depends on your web.config settings and IIS as to what account that is.


这篇关于将图像上传到我服务器中的文件夹时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆