Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem with image upload in 2008

Problem with image upload in 2008

Scheduled Pinned Locked Moved ASP.NET
graphicshelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hemant kaushal
    wrote on last edited by
    #1

    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.

    S 1 Reply Last reply
    0
    • H hemant kaushal

      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.

      S Offline
      S Offline
      sashidhar
      wrote on last edited by
      #2

      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.

      H 1 Reply Last reply
      0
      • S sashidhar

        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.

        H Offline
        H Offline
        hemant kaushal
        wrote on last edited by
        #3

        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 ratio

                    if (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);

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups