I need to save the files somewhere else because the server that this application is getting full
How would I change the virtual path to a physical path?
This is my original controller
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(FormularioDoUploadViewModel formularioDoUploadViewModel)
{
if (ModelState.IsValid)
{
List<DetalhesDoArquivoViewModel> detalhesDosArquivos = new List<DetalhesDoArquivoViewModel>();
for (int i = 0; i < Request.Files.Count; i++)
{
var file = Request.Files[i];
if (file != null && file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
DetalhesDoArquivoViewModel detalhesDoArquivo = new DetalhesDoArquivoViewModel()
{
FileName = fileName,
Extension = Path.GetExtension(fileName)
};
detalhesDosArquivos.Add(detalhesDoArquivo);
var path = Path.Combine(Server.MapPath(@"~/App_Data/Upload/"), detalhesDoArquivo.Id + detalhesDoArquivo.Extension);
file.SaveAs(path);
}
}
formularioDoUploadViewModel.DetalhesDoArquivo = detalhesDosArquivos;
_uploadServices.AdicionarArquivo(formularioDoUploadViewModel);
return RedirectToAction("Index");
}
return View(formularioDoUploadViewModel);
}
and I want to insert this path into the variable path:
var path = Path.Combine(Server.MapPath(@"C:\Users\bwm6\Desktop\uploads"), detalhesDoArquivo.Id + detalhesDoArquivo.Extension);