user3448123
user3448123

Reputation: 31

Simple file upload on Windows Azure

I am trying to upload a file on windows Azure but have no luck. My website is developed using ASP.NET MVC5 in VS2013. It works fine on my local machine but when I publish it on Windows Azure it gives me an error:

Could not find a part of the path 'D:\home\site\wwwroot\Uploads\bluedress_21-03-2014.jpg'.

This is the code I am using:

If file.ContentLength > 0 Then
   Dim fileName = Path.GetFileName(file.FileName)
   Dim fileNameWithoutExt = Path.GetFileNameWithoutExtension(file.FileName)
   Dim Ext = Path.GetExtension(file.FileName)
   Dim fileNameToSave = fileNameWithoutExt & "_" & Date.Now.ToString("dd-MM-yyyy") & Ext
   Dim path__1 = Path.Combine(Server.MapPath("~/Uploads/"), fileNameToSave)  
      advert.ImageLocation = fileNameToSave file.SaveAs(path__1)                     
End If

I have tried Googling the problem but found no solution at all. Can someone please help me?

Upvotes: 3

Views: 770

Answers (1)

terryt
terryt

Reputation: 561

When working with Azure Websites, the recommended practice is to upload files to Azure Storage. Any files uploaded to the virtual server will be lost if the role is switched out to use another VM. If you really need to do this for some reason, here is a link that may help: Windows Azure: Working with local storage

Upvotes: 3

Related Questions