Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 主机上上载图像的访问被拒绝_C#_Asp.net Core_Plesk - Fatal编程技术网

C# 主机上上载图像的访问被拒绝

C# 主机上上载图像的访问被拒绝,c#,asp.net-core,plesk,C#,Asp.net Core,Plesk,我使用以下代码将图像复制到路径 public async Task<object> UploadImage(IFormFile file) { string path = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\uploads\"); string fileName = file.FileName; string fullPath = Path.Combine(path, fileName)

我使用以下代码将图像复制到路径

public async Task<object> UploadImage(IFormFile file)
{
string path = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\uploads\");
string fileName = file.FileName;

string fullPath = Path.Combine(path, fileName);

await file.CopyToAsync(new FileStream(fullPath, FileMode.Create));
}

很少有东西需要检查和验证

确保在托管env时,您已经在wwwroot下创建了uploads目录。 如果不存在,创建它。 您必须授予将目录上载到应用程序运行所在的apppool Perimmission应用程序池的权限。 以上内容是必需的,您的代码是在apppool上下文下执行的

Access to the path C:\Inetpub\vhosts\site.com\wwwroot\uploads\file.png' is denied.