6 Replies Latest reply on May 21, 2007 10:43 AM by tclaremont

    store image into db

    Nick201 Level 1
      I am using sql server db. I would like to store image into db. How can i store image into db and read it after that.

      thanks
        • 1. Re: store image into db
          jdeline Level 1
          Unless there is a compelling reason for storing the image in the database, I'd suggest you store the image in an image directory and store the filename of the image in the database. For example, if you store myImage.jpg into a directory named imageDir, you can store the filename "myImage.jpg" in the database. To display the image, retrieve it as the variable showImage and display it using <IMG SRC="imageDir\#showImage#" ... >
          • 2. Re: store image into db
            tclaremont Level 2
            There is some debate as to what the recommended approach would be.

            I am of the opinion that storing the image itself in the database, while technically possible, is not the best solution for most of the scenarios I have come across.

            As has been suggested, I also recommend storing the image itself in a priviledged directory on your server, and then storing the filename to that image in your database.
            • 3. Re: store image into db
              Nick201 Level 1
              Thanks, You guys have any sample code.
              • 4. Re: store image into db
                tclaremont Level 2
                It depends on what you want to do.

                Are you allowing end users to upload images, and then referencing those images on a page, or are you, as the developer, maintaining the images and displaying them?
                • 5. Re: store image into db
                  Nick201 Level 1
                  I did figure it out. Only help i need how can i store multile image into db.
                  • 6. Re: store image into db
                    tclaremont Level 2
                    That depends on how your database is structured. If you anticipate mutlipe images per record in your DB, it might make sense to create a separate table with a one-to-many relationship between the main table and your images table. That would allow you the flexibility to store as many images as you want that relate to a single record in your main table.