how to store the image in database using php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vivekgoyal
    New Member
    • Sep 2007
    • 6

    how to store the image in database using php

    hello guys,
    i need your help...
    i face problem in storing image in database...
    can any one send me the complete coding of storing image in database...
    please i need ur help...
    plz try to send me complete coding of stroing image file in php...

    thanks and regards
    Vivek Goyal
  • gregerly
    Recognized Expert New Member
    • Sep 2006
    • 192

    #2
    Originally posted by vivekgoyal
    hello guys,
    i need your help...
    i face problem in storing image in database...
    can any one send me the complete coding of storing image in database...
    please i need ur help...
    plz try to send me complete coding of stroing image file in php...

    thanks and regards
    Vivek Goyal
    Hi vivekgoyal,

    We are here to help you when you have questions with projects you might be working on, not to do your projects for you. I'de be more than willing to help you if you have some code you want some help on. Post what you have so far and we can go from there.

    Thanks,

    greg

    Comment

    • abshirf2
      New Member
      • Aug 2007
      • 9

      #3
      Originally posted by vivekgoyal
      hello guys,
      i need your help...
      i face problem in storing image in database...
      can any one send me the complete coding of storing image in database...
      please i need ur help...
      plz try to send me complete coding of stroing image file in php...

      thanks and regards
      Vivek Goyal
      I wouldn't ask for code, its better to understand what your are doing yourself. Plus it may not be compatabile with what you already have

      Firstly i wouldn't store the images in a db, i would store the path to the image in the db and then retreive when you need it. i think you'll find thats simpler.

      Comment

      • aktar
        New Member
        • Jul 2006
        • 105

        #4
        Hi Vivek

        It really very easy: all you do is prepare a a DB slot(long blob) and store in it your image handle. The code below assumes you know how to upload using HTML

        [php]


        $handle = fopen($_FILE['file']['tmp_name'], "r");

        $sql = "INSERT INTO image (image, .... ......) ";
        $sql .= "VALUES ('$handle' .. .....)";

        //then insert and WALLA!!! there you have it

        [/php]


        But I wouldnt recomment this method for many reasons. Instead you should store the image as a file and put the NAME of the image into the DB

        This might help you, as it has complete example codes

        Join Us Step-by-Step on the Journey to Becoming a Programmer in 2025. We'll be Kicking Things Off with a Comprehensive Beginner's Guide to Swift!

        Comment

        Working...