[英]File uploading into server
我正在制作一个具有图像上传模块的网站。在我的本地主机服务器中,它运行正常。 这意味着我可以上传图像并保存。 但是,当我托管我的解决方案时,我得到了一个错误。 即,拒绝访问路径。
这是我使用的代码...
string fileName = FileUpload1.FileName.ToString();
string uploadFolderPath = "~/up_foto/";
string filePath = HttpContext.Current.Server.MapPath(uploadFolderPath);
FileUpload1.SaveAs(filePath + "\\" + fileName);`
这是怎么了..请帮助我....在此先谢谢....
如果代码在本地运行,恐怕代码没有问题。 相反,您必须确保在主机环境上,用户“ IUSER”或“ IIS_IUSER”等是否具有对上载文件夹的访问权限(读取/写入)。
由于您收到“拒绝访问路径”的信息,是否检查了要上传的文件夹是否具有写权限
您可以使用Path.combine或server.mappath(不要忘记在名称空间中添加System.IO)
string fileName = FileUpload1.FileName.ToString();
string uploadFolderPath = "~/Uploads/Images/";
string filePath1 = Server.MapPath(uploadFolderPath + fileName);
要么
string fileName = FileUpload1.FileName.ToString();
string uploadFolderPath = "~/Uploads/Images/";
string filePath = Server.MapPath(uploadFolderPath);
string filePath1= Path.Combine(filepath1 + fileName);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.