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. Uploaded image into thumbnail

Uploaded image into thumbnail

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelp
12 Posts 4 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.
  • J Offline
    J Offline
    jai 123
    wrote on last edited by
    #1

    hi to all, I am using asp.net 2.0, in that I designed a webpage for uploading an image. If the user uploads an image it should be automatically change in to thumbnail and it is displayed in that website. I searched in Google but I didn’t get the proper coding for that. So, please help.

    jai prakash

    P 1 Reply Last reply
    0
    • J jai 123

      hi to all, I am using asp.net 2.0, in that I designed a webpage for uploading an image. If the user uploads an image it should be automatically change in to thumbnail and it is displayed in that website. I searched in Google but I didn’t get the proper coding for that. So, please help.

      jai prakash

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      Why have you posted your question again? You only posted your original question 30mins ago. Don't you know that it is rude to do this? You won't necessarily get an immediate response to your question. This is a free site, so unless you are going to pay someone for advice you should be prepared to wait. I've answered your first post. Please read it and remember not to double-post in future.

      Paul Marfleet

      J P 2 Replies Last reply
      0
      • P pmarfleet

        Why have you posted your question again? You only posted your original question 30mins ago. Don't you know that it is rude to do this? You won't necessarily get an immediate response to your question. This is a free site, so unless you are going to pay someone for advice you should be prepared to wait. I've answered your first post. Please read it and remember not to double-post in future.

        Paul Marfleet

        J Offline
        J Offline
        jai 123
        wrote on last edited by
        #3

        sorry ya,here after i will not do it. I cont get a clear idea from that link. Is there any other link for full code. Please help me.

        jai

        P A 2 Replies Last reply
        0
        • J jai 123

          sorry ya,here after i will not do it. I cont get a clear idea from that link. Is there any other link for full code. Please help me.

          jai

          P Offline
          P Offline
          pmarfleet
          wrote on last edited by
          #4

          I gave you the link to the documentation that shows you how to use the Image.GetThumbnailImage method to create a thumbnail image. The other tasks - uploading an image, saving an image to the file system, displaying an image in a web page should be trivial. What is it that you don't understand? There will be plenty of examples on the web to implement these individual tasks if you search for them. You're not going to find a single article where you can cut-and-paste the code to immediately solve your problem. As a developer, you should be able to apply your problem-solving and research skills to find a solution. It's not going to be handed on a plate to you.

          Paul Marfleet

          1 Reply Last reply
          0
          • J jai 123

            sorry ya,here after i will not do it. I cont get a clear idea from that link. Is there any other link for full code. Please help me.

            jai

            A Offline
            A Offline
            Abhijit Jana
            wrote on last edited by
            #5

            Hi, Jai, I have sending you the code from one of my application, please change it accordingly and let me know when done...... :) And it's only for jpg, and u cna do it for any one..... :) :) :) protected void Button2_Click(object sender, EventArgs e) { string sSavePath; string sThumbExtension; int intThumbWidth; int intThumbHeight; sSavePath = _Default.fullpath; sThumbExtension = "_thumb"; intThumbWidth = 160; intThumbHeight = 120; // If file field isn’t empty if (FileUpload1.PostedFile != null) { // Check file size (mustn’t be 0) HttpPostedFile myFile = FileUpload1.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen == 0) { lblOutput.Text = "No file was uploaded."; return; } // Check file extension (must be JPG) if (System.IO.Path.GetExtension(myFile.FileName).ToLower() != ".jpg") { lblOutput.Text = "The file must have an extension of JPG"; return; } // Read file into a data stream byte[] myData = new Byte[nFileLen]; myFile.InputStream.Read(myData, 0, nFileLen); // Make sure a duplicate file doesn’t exist. If it does, keep on appending an // incremental numeric until it is unique string sFilename = System.IO.Path.GetFileName(myFile.FileName); int file_append = 0; while (System.IO.File.Exists(( (sSavePath + sFilename)))) { file_append++; sFilename = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) + file_append.ToString() + ".jpg"; } // Save the stream to disk System.IO.FileStream newFile = new System.IO.FileStream((sSavePath + sFilename), System.IO.FileMode.Create); newFile.Write(myData, 0, myData.Length); newFile.Close(); // Check whether the file is really a JPEG by opening it System.Drawing.Image.GetThumbnailImageAbort myCallBack = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback); Bitmap myBitmap; try { myBitmap = new Bitmap((sSavePath + sFilename)); // If jpg file is a jpeg, create a thumbnail filename that is unique. file_append = 0; string sThumbFile = System.IO.Path.GetFileNam

            J 1 Reply Last reply
            0
            • A Abhijit Jana

              Hi, Jai, I have sending you the code from one of my application, please change it accordingly and let me know when done...... :) And it's only for jpg, and u cna do it for any one..... :) :) :) protected void Button2_Click(object sender, EventArgs e) { string sSavePath; string sThumbExtension; int intThumbWidth; int intThumbHeight; sSavePath = _Default.fullpath; sThumbExtension = "_thumb"; intThumbWidth = 160; intThumbHeight = 120; // If file field isn’t empty if (FileUpload1.PostedFile != null) { // Check file size (mustn’t be 0) HttpPostedFile myFile = FileUpload1.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen == 0) { lblOutput.Text = "No file was uploaded."; return; } // Check file extension (must be JPG) if (System.IO.Path.GetExtension(myFile.FileName).ToLower() != ".jpg") { lblOutput.Text = "The file must have an extension of JPG"; return; } // Read file into a data stream byte[] myData = new Byte[nFileLen]; myFile.InputStream.Read(myData, 0, nFileLen); // Make sure a duplicate file doesn’t exist. If it does, keep on appending an // incremental numeric until it is unique string sFilename = System.IO.Path.GetFileName(myFile.FileName); int file_append = 0; while (System.IO.File.Exists(( (sSavePath + sFilename)))) { file_append++; sFilename = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) + file_append.ToString() + ".jpg"; } // Save the stream to disk System.IO.FileStream newFile = new System.IO.FileStream((sSavePath + sFilename), System.IO.FileMode.Create); newFile.Write(myData, 0, myData.Length); newFile.Close(); // Check whether the file is really a JPEG by opening it System.Drawing.Image.GetThumbnailImageAbort myCallBack = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback); Bitmap myBitmap; try { myBitmap = new Bitmap((sSavePath + sFilename)); // If jpg file is a jpeg, create a thumbnail filename that is unique. file_append = 0; string sThumbFile = System.IO.Path.GetFileNam

              J Offline
              J Offline
              jai 123
              wrote on last edited by
              #6

              hi Abhijit Jana, please send me the html coding also thanks

              jai prakash

              A 1 Reply Last reply
              0
              • J jai 123

                hi Abhijit Jana, please send me the html coding also thanks

                jai prakash

                A Offline
                A Offline
                Abhijit Jana
                wrote on last edited by
                #7

                Html, Coding, is very big one becuase , Image uploading is a small part of the page, u can test it using Create a ImageBox, Take a fileupload control and 1 button put the code in Button_1 Click { } and in outsides.... ThumbnailCallback() Any query ask me !!!! :)

                Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

                J 1 Reply Last reply
                0
                • A Abhijit Jana

                  Html, Coding, is very big one becuase , Image uploading is a small part of the page, u can test it using Create a ImageBox, Take a fileupload control and 1 button put the code in Button_1 Click { } and in outsides.... ThumbnailCallback() Any query ask me !!!! :)

                  Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

                  J Offline
                  J Offline
                  jai 123
                  wrote on last edited by
                  #8

                  hi Abhijit Jana, what should i want to give in sThumbExtension = " ";

                  jai prakash

                  A 1 Reply Last reply
                  0
                  • J jai 123

                    hi Abhijit Jana, what should i want to give in sThumbExtension = " ";

                    jai prakash

                    A Offline
                    A Offline
                    Abhijit Jana
                    wrote on last edited by
                    #9

                    Hi jai,

                    jai aswitha wrote:

                    sThumbExtension = " ";

                    I have mention sThumbExtension ="_thumbs" u can give anything.... If you uplaod a file with abhijit.jpg then its thumbs should be abhijit_thumbs.jpg:cool: is it clear ??? or you want to ask some think different !!!!:confused:

                    Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

                    1 Reply Last reply
                    0
                    • P pmarfleet

                      Why have you posted your question again? You only posted your original question 30mins ago. Don't you know that it is rude to do this? You won't necessarily get an immediate response to your question. This is a free site, so unless you are going to pay someone for advice you should be prepared to wait. I've answered your first post. Please read it and remember not to double-post in future.

                      Paul Marfleet

                      P Offline
                      P Offline
                      Padma N
                      wrote on last edited by
                      #10

                      i am also having pblm related to this .can i get this path pls.

                      A P 2 Replies Last reply
                      0
                      • P Padma N

                        i am also having pblm related to this .can i get this path pls.

                        A Offline
                        A Offline
                        Abhijit Jana
                        wrote on last edited by
                        #11

                        Please check my reply to jai, for the same !!!

                        Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

                        1 Reply Last reply
                        0
                        • P Padma N

                          i am also having pblm related to this .can i get this path pls.

                          P Offline
                          P Offline
                          pmarfleet
                          wrote on last edited by
                          #12

                          Why? Don't you have the ability to search the forum yourself? Also, please don't use textspeak. It's really irritating.

                          Paul Marfleet

                          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