Problem with image upload in 2008
-
MemoryStream stream = new MemoryStream(thumbnail);
Bitmap bmp = (Bitmap)System.Drawing.Image.FromStream(stream);
i m using above code for image uploading in 2005 and it is working properly but same code is throwing exception "Parameter is not valid." on line
Bitmap bmp = (Bitmap)System.Drawing.Image.FromStream(stream);
is there any issue with 2008 or there is some other way in it.
-
MemoryStream stream = new MemoryStream(thumbnail);
Bitmap bmp = (Bitmap)System.Drawing.Image.FromStream(stream);
i m using above code for image uploading in 2005 and it is working properly but same code is throwing exception "Parameter is not valid." on line
Bitmap bmp = (Bitmap)System.Drawing.Image.FromStream(stream);
is there any issue with 2008 or there is some other way in it.
-
I have no idea what you are doing...! Are you converting into bytes? What ar you trying to do..!
LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.
I m trying to create thumbnail image of uploaded image
{ image = new byte\[len\]; updFIle.PostedFile.InputStream.Read(image, 0, len); ImageUtility objImage = new ImageUtility(); timage = objImage.UpdateGalleryphoto(filemime, len, image, 100, 100); filename = updFIle.FileName; BL.clsAdmin obj = new BL.clsAdmin(); //DataTable dt = obj.uploadImage(Request.QueryString\["prop"\].ToString(), image, timage, txtCaption.Text, filename, filemime);
} updateGallery photo is function which generates the thumbnail
public byte[] UpdateGalleryphoto(String strImageType, int len, byte[] thumbnail, int height,int width)
{
byte[] Thumbpic = null;
try
{
int EH = 75; // Max height of thumbnail
int EW = 100;//= 100; // Max width of thumbnail
Thumbpic = new byte[len];
MemoryStream stream = new MemoryStream(thumbnail);
Bitmap bmp = (Bitmap)System.Drawing.Image.FromStream(stream);
int w = bmp.Width;
int h = bmp.Height;
bool bImage = false;
// Adjust hegith or width on basic of width or height whichever is greater on same ratioif (height >= h && width >= w) { return thumbnail; } if (h >height) { EW = (EH \* w) / h; } else { EH = (EW \* h) / w; } Thumbpic = ModifyImage(thumbnail, EW, EH, strImageType, bImage); } catch (Exception ex) { throw ex; } return Thumbpic; }
above code is working in 2005 but throwing exception in 2008 at line
Bitmap bmp = (Bitmap)System.Drawing.Image.FromStream(stream);