ASP.NET Image Upload Parameter Not Valid. Exception
- by pennylane
Hi Guys,
Im just trying to save a file to disk using a posted stream from jquery uploadify
I'm also getting Parameter not valid.
On adding to the error message so i can tell where it blew up in production im seeing it blow up on: var postedBitmap = new Bitmap(postedFileStream)
any help would be most appreciated
public string SaveImageFile(Stream postedFileStream, string fileDirectory, string fileName, int imageWidth, int imageHeight)
{
string result = "";
string fullFilePath = Path.Combine(fileDirectory, fileName);
string exhelp = "";
if (!File.Exists(fullFilePath))
{
try
{
using (var postedBitmap = new Bitmap(postedFileStream))
{
exhelp += "got past bmp creation" + fullFilePath;
using (var imageToSave = ImageHandler.ResizeImage(postedBitmap, imageWidth, imageHeight))
{
exhelp += "got past resize";
if (!Directory.Exists(fileDirectory))
{
Directory.CreateDirectory(fileDirectory);
}
result = "Success";
postedBitmap.Dispose();
imageToSave.Save(fullFilePath, GetImageFormatForFile(fileName));
}
exhelp += "got past save";
}
}
catch (Exception ex)
{
result = "Save Image File Failed " + ex.Message + ex.StackTrace;
Global.SendExceptionEmail("Save Image File Failed " + exhelp, ex);
}
}
return result;
}