I have this project deployed on azure website (running on one instance) that gets different fields (name, age, ...) and also allows an upload of an image. All data is then stored in an azure database.
The problem is that I can't save the uploaded file. It works fine locally but when deployed I get the "Could not find a part of the path 'D:...." error.
I have tried saving the file in Temp and localresources but I must be missing something or implementing incorrectly, I also don't have access to the blob Storage.
How can I properly save the uploaded file (which I would like to store in a db)?
This is how and where I'm trying to save the image:
[HttpPost]
public ActionResult Create(HttpPostedFileBase file, [Bind(Include = "StudentId,Name,Age")] student13 student13)
{
if (file != null && file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
file.SaveAs(path);
}
This is the view:
<form action="" method="post" enctype="multipart/form-data">
<label for="file">picture:</label>
<input type="file" name="file" id="file" class="form-control" />
<input type="submit" class="btn btn-default" value="Create" />
</form>