I wrote some codes to upload a file in an ASP.NET MVC3 project. Instead of storing the file in the database, I downloaded the files in the file system and saved the paths in the database.
The download codes are as follows: -
if (file != null && file.ContentLength > 0)
{
if (path == null)
{
throw new ArgumentNullException("path cannot be null");
}
string pFileName = PrefixFName(file.FileName);
String relpath = String.Format("{0}/{1}", path, pFileName);
try
{
file.SaveAs(Server.MapPath(relpath));
return pFileName;
}
catch (HttpException e)
{
throw new ApplicationException("Cannot save uploaded file", e);
}
}
After saving the file, I used this image with the image tag in several views. My codes work great locally. But when I posted the site at windowsazure.com, everything worked, but the file was uploaded.
How can I get rid of this situation? Please, help.
source
share