I am currently developing a web application in c# (ASP.NET MVC).
I need to upload images on this site, and right now I am saving the images in a folder locally, like this:
[HttpPost]
public ActionResult Create(Product product, HttpPostedFileBase file)
{
if (!ModelState.IsValid)
{
return View(product);
}
else
{
if (file != null)
{
product.Image = product.Id + Path.GetExtension(file.FileName);
file.SaveAs(Server.MapPath("//Content//ProductImages//") + product.Image);
}
context.Insert(product);
context.Commit();
return RedirectToAction("Index");
}
}
As you can see, I am storing my images in the folder 'ProductImages'. The ID's of these images are then stored in a database-table, so I will later be able to fetch the images by ID.
Now, the problem here is, that I would rather have my image folder stored on a seperate server, so it doesn't take up space on the server on which I have my project and db deployed.
I have read that this method will make the loading speed a lot faster, since images can be a pain to process due to their size.
How would I go about this?
Thanks in advance