Thanks Terry, another thing.. I have this function that resize images before it copies the image to my server;
- private void ItemPicture_FileUploaded(object sender, UploaderEventArgs args)
- {
- if (GetVisibleItemCount() >= 5)
- return;
-
- using (System.IO.Stream stream = args.OpenStream())
- {
- ItemPictureAttachments.Upload(args.FileSize, args.FileName, ResizeFromStream(640, stream));
-
- }
- }
-
- public Stream ResizeFromStream(int MaxSideSize, Stream Buffer)
- {
- int intNewWidth;
- int intNewHeight;
- System.Drawing.Image imgInput = System.Drawing.Image.FromStream(Buffer);
-
-
- ImageFormat fmtImageFormat = imgInput.RawFormat;
-
-
- int intOldWidth = imgInput.Width;
- int intOldHeight = imgInput.Height;
-
-
- int intMaxSide;
-
- if (intOldWidth >= intOldHeight)
- {
- intMaxSide = intOldWidth;
- }
- else
- {
- intMaxSide = intOldHeight;
- }
-
-
- if (intMaxSide > MaxSideSize)
- {
-
- double dblCoef = MaxSideSize / (double)intMaxSide;
- intNewWidth = Convert.ToInt32(dblCoef * intOldWidth);
- intNewHeight = Convert.ToInt32(dblCoef * intOldHeight);
- }
- else
- {
- intNewWidth = intOldWidth;
- intNewHeight = intOldHeight;
- }
-
-
- Bitmap bmpResized = new Bitmap(imgInput, intNewWidth, intNewHeight);
-
-
-
- MemoryStream imgStream = new MemoryStream();
- bmpResized.Save(imgStream, imgInput.RawFormat);
-
-
- imgInput.Dispose();
- bmpResized.Dispose();
- Buffer.Close();
-
- return imgStream;
- }
But for some reason it return a file with 0 bytes and copies this empty file into my server. What am I missing?
Thanks,
- Ryan