How to store Image into databse

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mmr315
    New Member
    • Aug 2007
    • 25

    How to store Image into databse

    Please give me sample code to insert image into database


    regards
    madhu
  • FrEaKmAn
    New Member
    • Aug 2007
    • 46

    #2
    well this doesn't really answer your question, but why do you want to store image in db? as I know, it's not such a good idea..

    Comment

    • ak1dnar
      Recognized Expert Top Contributor
      • Jan 2007
      • 1584

      #3
      Originally posted by mmr315
      Please give me sample code to insert image into database


      regards
      madhu
      You have to use mysql blob data type for store images.
      Please read through this tutorial first and post back questions if any.

      Comment

      • mwasif
        Recognized Expert Contributor
        • Jul 2006
        • 802

        #4
        You may find this post useful.

        Comment

        • ronnil
          Recognized Expert New Member
          • Jun 2007
          • 134

          #5
          Originally posted by FrEaKmAn
          well this doesn't really answer your question, but why do you want to store image in db? as I know, it's not such a good idea..
          Personally i don't think it's such a bad idea, as long as your site isn't visited as much. The reason it's a bad idea is that it's a really slow process reading so much data from a database.
          BUT for security reasons, this could very well be a good idea since the only way you can access the pictures, is through a server side language.

          If possible, it's better to store images and files over you webroot, and then access them stil through php, this is a quicker way to do it, and you can still stop people from leeching and that kind of things.

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Heya, Madhu.

            TSDN members are expected to write their own code. We're happy to help you out if you have specific questions, but you can't realistically expect someone to do your coding for you on a free forum.

            Comment

            • MarkoKlacar
              Recognized Expert Contributor
              • Aug 2007
              • 296

              #7
              When creating your table create all the fields you need, as well a MEDIUMBLOB for storing you image.

              When uploading the image specify you SQL-query so that the variable containing the image is sent in to the database just as you would send a string or integer. Pretty simple, just treat it as any other entry.

              Retrieveing the image is a bit more complicated, are you going to need help with this as well?

              Comment

              Working...