Reputation: 699
I am making a self hosted asp.net core application with version 2.0
I am having problems uploading images to be displayed on the webpage. I want the images to be placed under wwwroot, but on my windows pc, the wwwroot is located under program files/my app folder, where I need admin rights to write. (besides it being a nasty place to put the files) How can I change the location of the wwwroot? and/or change the location of where the files are uploaded to. And how do I set the path in the src to point to under wwwroot / where ever I place it on disc?
Upvotes: 1
Views: 385
Reputation: 1633
Create a new physical file provider:
public class UserFilesProvider : PhysicalFileProvider
{
public UserFilesProvider() : base(@"C:\Path\To\wwwroot") { }
}
Pass your physical files provider to StaticFileOptions
in Startup.Configure
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new UserFilesProvider();
}
You will still need to grant permissions to the new folder, but this will let you assign the location of that folder.
Upvotes: 2