Reputation: 9580
I created a basic drag and drop image upload user interface in a .Net MVC application. I just save the image to the server using very basic code, this works locally , but after I deploy to Azure I get a javascript alert that pops up saying "Internal Server Error" which is weird because no where in my code do I have anything to show an alert with the status.
here is the code I tried:
(basically taken from Phil Haack article)
public ActionResult UploadPhoto(HttpPostedFileBase file)
{
if (file.ContentLength > 0)
{
var splitFileName = file.FileName.Split('.');
var type = splitFileName[splitFileName.Length - 1];
var fileName = User.Identity.Name;
var path = "/Content/Users/" + fileName + "." + type;
var pathToSave = Path.Combine(Server.MapPath("~/Content/Users"), fileName + "." + type);
file.SaveAs(pathToSave);
}
return Json("All files have been successfully stored.");
}
something is preventing this upload from happening on Azure , anyone have any ideas?
Upvotes: 0
Views: 561
Reputation: 713
You cannot upload images to azure web servers like that. Your website does not have permissions to make changes to file systems outside of publishing. You will have to use Blob or CDN services provided by Azure or another service to host user uploaded content.
Upvotes: 1