PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, November 13, 2022

[FIXED] How to save file based on relative or virtual path when using plesk?

 November 13, 2022     asp.net-mvc, c#, plesk     No comments   

Issue

I have a program in asp.Net MVC. My server is plesk.

I save my files using this method:

public string SaveFile(HttpPostedFileBase file, string path)
{
    string fileName = Guid.NewGuid() + file.FileName;
    var filePath = Path.Combine(Server.MapPath("~/Images/"), fileName);
    file.SaveAs(filePath);
    return fileName;
}

and file saving is OK in test computer. But after uploading on server I get this error:

Could not find a part of the path 'C:\Inetpub\vhosts\hostname.com\mysitename.com\Images\myFile.jpg'

What is wrong with my code? Should I use something different when using plesk?


Solution

OK then, most likely it is because your IIS user does not have write permission to write on that folder. Add full permission on the folder. The user must be something like: Plesk IIS WP User.

You can simply allow write/modify permission for subscription in Hosting Settings:

ASP .NET Plesk permissions file



Answered By - Mahdi
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing