Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

retrieving then displaying BLOB image

Avatar of amchugh89
amchugh89 asked on
12 Comments1 Solution700 ViewsLast Modified:
i have a php code that sucessfully uploads image data into my database table.
Now I need to retrieve and display the image on another page. how the heck do I do this.
I've trolled forums but most of them have conflicting or downright incorrect ways to do it.

Heres my code for uploading the stuff to my database (one picture is uploaded into a single row corresponding to the user who updated that photo for there home page)
I am assuming the following code works, because the 'image column is uploaded with a file that is the same # of kB as picture the thing im uploading.

  <title> Upload Image </title>
   <form action = "upload2.php" method ="POST" enctype ="multipart/form-data">
     <input type ="file" name = "image"> <input type = "submit" value = "Upload">
       include "database.php";
       $username = $_COOKIE['ID_my_site'];

   $file = $_FILES['image']['tmp_name'];
       echo "Select an image";
         $image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
         $image_name = addslashes($_FILES['image']['name']);
         $image_size = getimagesize($_FILES['image']['tmp_name']);

        if($image_size == FALSE)
        echo "Thats not am image.";
         if (!$insert = mysql_query("UPDATE users SET image = '$image'
WHERE username = '$username'"))
        echo "Problem uploading image. Possible that file is too large";
Sucessfully Uploaded!