文件上载的时候提示上载的路径拒绝访问,上载路径的文件夹我已经设置成everyone完全控制
一下为主要代码:
<table>
<tr>
<td align="left" width="12%" colspan="2"> <asp:Label ID="up" Runat="server">文件上载:</asp:Label>
<INPUT type="file" size="50" NAME="File">
<asp:Button Runat="server" Text="开始上传" ID="Button1"></asp:Button> <input onclick="this.form.reset()" type="button" value="重置(ReSet)">
<asp:Label id="Label2" runat="server" Font-Names="宋体" Font-Bold="True" Font-Size="9pt" Width="500px"
BorderStyle="None" BorderColor="White"></asp:Label>
</td>
</tr>
<tr>
<asp:Label id="strStatus" runat="server" Font-Names="宋体" Font-Bold="True" Font-Size="9pt" Width="500px"
BorderStyle="None" BorderColor="White"></asp:Label>
</tr>
</table>后台(C#):private Boolean SaveImages()
{
///'遍历File表单元素
HttpFileCollection files = HttpContext.Current.Request.Files; /// '状态信息
System.Text.StringBuilder strMsg = new System.Text.StringBuilder();
strMsg.Append("上传的文件是:<hr color=red>");
try
{
for(int iFile = 0; iFile < files.Count; iFile++)
{
///'检查文件扩展名字
HttpPostedFile postedFile = files[iFile];
string fileName, fileExtension;
fileName = System.IO.Path.GetFileName(postedFile.FileName);
if (fileName != "")
{
fileExtension = System.IO.Path.GetExtension(fileName);
strMsg.Append("上传的文件类型:" + postedFile.ContentType.ToString() + "<br>");
strMsg.Append("客户端文件地址:" + postedFile.FileName + "<br>");
strMsg.Append("上传文件的文件名:" + fileName + "<br>");
strMsg.Append("上传文件的扩展名:" + fileExtension + "<br><hr>");
///'可根据扩展名字的不同保存到不同的文件夹
postedFile.SaveAs(("//\\10.1.30.41\\software\\") + fileName);
}
}
strStatus.Text = strMsg.ToString();
return true;
}
catch(System.Exception Ex)
{
strStatus.Text = Ex.Message;
return false;
} }
一下为主要代码:
<table>
<tr>
<td align="left" width="12%" colspan="2"> <asp:Label ID="up" Runat="server">文件上载:</asp:Label>
<INPUT type="file" size="50" NAME="File">
<asp:Button Runat="server" Text="开始上传" ID="Button1"></asp:Button> <input onclick="this.form.reset()" type="button" value="重置(ReSet)">
<asp:Label id="Label2" runat="server" Font-Names="宋体" Font-Bold="True" Font-Size="9pt" Width="500px"
BorderStyle="None" BorderColor="White"></asp:Label>
</td>
</tr>
<tr>
<asp:Label id="strStatus" runat="server" Font-Names="宋体" Font-Bold="True" Font-Size="9pt" Width="500px"
BorderStyle="None" BorderColor="White"></asp:Label>
</tr>
</table>后台(C#):private Boolean SaveImages()
{
///'遍历File表单元素
HttpFileCollection files = HttpContext.Current.Request.Files; /// '状态信息
System.Text.StringBuilder strMsg = new System.Text.StringBuilder();
strMsg.Append("上传的文件是:<hr color=red>");
try
{
for(int iFile = 0; iFile < files.Count; iFile++)
{
///'检查文件扩展名字
HttpPostedFile postedFile = files[iFile];
string fileName, fileExtension;
fileName = System.IO.Path.GetFileName(postedFile.FileName);
if (fileName != "")
{
fileExtension = System.IO.Path.GetExtension(fileName);
strMsg.Append("上传的文件类型:" + postedFile.ContentType.ToString() + "<br>");
strMsg.Append("客户端文件地址:" + postedFile.FileName + "<br>");
strMsg.Append("上传文件的文件名:" + fileName + "<br>");
strMsg.Append("上传文件的扩展名:" + fileExtension + "<br><hr>");
///'可根据扩展名字的不同保存到不同的文件夹
postedFile.SaveAs(("//\\10.1.30.41\\software\\") + fileName);
}
}
strStatus.Text = strMsg.ToString();
return true;
}
catch(System.Exception Ex)
{
strStatus.Text = Ex.Message;
return false;
} }
解决方案 »
- 为什么用了母版页 css居中无效了
- 相关asp.net定时任务
- 图灵系列的书好还是wrox红皮书系列的好?
- 大家的学历报一下哦,方便的话留下工资情况!
- 急,急!!用什么方法能从OleDbDataReader中取出2进制对象,又如何能判断2进制对象是否为空
- 在DataList中放了CheckBoxList控件,为会不响应DataList的ItemCommand事件?
- forms验证的一个小问题,请来看看,谢谢了!
- silverlight的PATH直线移动?
- 请问ASP.Net中含有水晶报表时该怎么部署?
- 关于asp.net中,服务器控件和javascript的问题.
- aspx里怎么接受另一个页面用JS传递过来的值
- 关于session的一个问题?
IIS估计没有这么大的权限吧.你先试试本地可以不
然后在web.config设置一个帐号...另外一台机子加一个相同帐号..
然后程序看看怎么写吧..只给个思路.具体我也不会.
还是从你的程序设计上着手考虑吧。另外不需要everyone完全控制,权限太大了
Asp.net写入权限就够了
<!-- 设置可接受的最大字节数 -->
<httpRuntime maxRequestLength="40960" executionTimeout="36000" >
</httpRuntime>