从客户端到服务器的文件上传错误. [英] Error in file upload from client to server.

查看:174
本文介绍了从客户端到服务器的文件上传错误.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试从文件上载控件中将某些文件从客户端上载到服务器.此代码在本地计算机上正常工作.并上传文件.但是托管后会出现以下错误:

错误:拒绝访问路径G:PleskVhostsexamcart.inhttpdocsDochindi.jpg.

我们正在使用asp.net 4.0.如果有任何权限问题.然后我们如何提供对远程服务器或iis的许可.

我尝试过的事情:

we are try to upload some file from file upload control from client to server. this code is proper working in local machine. and upload files. but after hosting it gives following error:

Error: Access to the path G:PleskVhostsexamcart.inhttpdocsDochindi.jpg is denied.

we are using asp.net 4.0. if there is any permission problem. then how we provide permission on remote server or iis.

What I have tried:

if (FileUpload1.HasFile)
{
    FileUpload1.SaveAs(Server.MapPath("~/Doc/") + TxtFileName.Text.Trim() + 
    System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName));
}



我们还尝试了以下方法.但会产生相同的错误:



we also tried following. but generate same error:

if (FileUpload1.HasFile)
{
    FileUpload1.SaveAs(Server.MapPath("~//Doc//") + TxtFileName.Text.Trim() + 
    System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName));
}

推荐答案

您需要设置一个具有权限的帐户,然后在IIS中的应用程序池"上更改该帐户以使用新帐户.这就是您的代码运行所用的帐户.
You need to setup an account that has permissions and then change the account on the Application Pool in IIS to use the new account. That is what account your code is running as.


这篇关于从客户端到服务器的文件上传错误.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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