<%@ Page language=C# Debug="true" %>
<%@ import Namespace="System.IO" %>
<script language="c#" runat=server>
void SubmitImage(Object sender,EventArgs e){
HttpPostedFile UpFile=UP_File.PostedFile;
if(UpFile==null||UpFile.ContentLength==0){
message.Text="<b>!请选择图像文件</b>";
}
else{
UpFile.SaveAs(Server.MapPath("images")+"/"+Path.GetFileName(UpFile.FileName));
message.Text="@图像上传成功!";
}
}</script>
<html>
<head><title>上传图像示例</title></head>
<body>
<form enctype="multipart/form-data" runat="server">
<h1>上传图像示例</h1>
<asp:Table runat="server" width="700" align="left">
<asp:TableRow>
<asp:TableCell>上传图像:</asp:TableCell>
<asp:TableCell><input type="file" id="UP_File" runat="server" Size="54" accesskey="image/*" /></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell> </asp:TableCell>
<asp:TableCell><asp:Button runat="server" width="50" OnClick="SubmitImage" text="上传" /></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell><asp:Label id="message" runat="server" forecolor="red" maintainstate="false" /></asp:TableCell>
<asp:TableCell> </asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>
</html>
上传图像后发生的异常: 怎么解决呀?对路径“F:\voice\上传文件\images\170741.jpg”的访问被拒绝。异常详细信息: System.UnauthorizedAccessException: 对路径“F:\voice\上传文件\images\170741.jpg”的访问被拒绝。 ASP.NET 未被授权访问所请求的资源。请考虑授予 ASP.NET 请求标识访问此资源的权限。ASP.NET 有一个在应用程序没有模拟时使用的基进程标识(通常,在 IIS 5 上为 {MACHINE}\ASPNET,在 IIS 6 上为网络服务)。如果应用程序正在通过 <identity impersonate="true"/> 模拟,则标识将为匿名用户(通常为 IUSR_MACHINENAME)或经过身份验证的请求用户。 若要授予 ASP.NET 对文件的写访问权,请在资源管理器中右击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”添加适当的用户或组。突出显示 ASP.NET 帐户,选中所需访问权限对应的框。
<%@ import Namespace="System.IO" %>
<script language="c#" runat=server>
void SubmitImage(Object sender,EventArgs e){
HttpPostedFile UpFile=UP_File.PostedFile;
if(UpFile==null||UpFile.ContentLength==0){
message.Text="<b>!请选择图像文件</b>";
}
else{
UpFile.SaveAs(Server.MapPath("images")+"/"+Path.GetFileName(UpFile.FileName));
message.Text="@图像上传成功!";
}
}</script>
<html>
<head><title>上传图像示例</title></head>
<body>
<form enctype="multipart/form-data" runat="server">
<h1>上传图像示例</h1>
<asp:Table runat="server" width="700" align="left">
<asp:TableRow>
<asp:TableCell>上传图像:</asp:TableCell>
<asp:TableCell><input type="file" id="UP_File" runat="server" Size="54" accesskey="image/*" /></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell> </asp:TableCell>
<asp:TableCell><asp:Button runat="server" width="50" OnClick="SubmitImage" text="上传" /></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell><asp:Label id="message" runat="server" forecolor="red" maintainstate="false" /></asp:TableCell>
<asp:TableCell> </asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>
</html>
上传图像后发生的异常: 怎么解决呀?对路径“F:\voice\上传文件\images\170741.jpg”的访问被拒绝。异常详细信息: System.UnauthorizedAccessException: 对路径“F:\voice\上传文件\images\170741.jpg”的访问被拒绝。 ASP.NET 未被授权访问所请求的资源。请考虑授予 ASP.NET 请求标识访问此资源的权限。ASP.NET 有一个在应用程序没有模拟时使用的基进程标识(通常,在 IIS 5 上为 {MACHINE}\ASPNET,在 IIS 6 上为网络服务)。如果应用程序正在通过 <identity impersonate="true"/> 模拟,则标识将为匿名用户(通常为 IUSR_MACHINENAME)或经过身份验证的请求用户。 若要授予 ASP.NET 对文件的写访问权,请在资源管理器中右击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”添加适当的用户或组。突出显示 ASP.NET 帐户,选中所需访问权限对应的框。
郁闷了!
-----------------
如果你的文件夹所在的硬盘分区格式是NTFS,那么它肯定有这个选项,如果没有,那是因为你没有在资源管理器里面,工具,选项,查看,把"简单共享"选项去除.