Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
reading image from mysql

Posted by fastlife (fastlife), 24 October 2007
Hi,

http://www.wellho.net/solutions/php-example-php-form-image-upload-store-in-mysql-database-retreive.html

i am using this code with little modification like i have moved // Insert any new image into database
code to a separate file.

and reading image in a different file.  My problem is that it is not showing image instead it is showing me binary data. (I want to print it in the page every time it loads) Please help me

Regards,
Madhulika



Posted by admin (Graham Ellis), 25 October 2007
I'm guessing that you haven't added a call to the PHP header function to set the content type, but without seeing you code that has to be a guess

Posted by fastlife (fastlife), 25 October 2007
thanks for replaying.

I am pasting piece code for you to view.

<tr>
                 <td width="100%" colspan="3">
                 <p align="center"><b>
                 <font face="Verdana" size="2" color="#515151">MODIFY USER                </font></b></td>
               </tr>
                       <tr>
                 <td width="8%">&nbsp;</td>
                 <td width="21%">&nbsp;</td>
                 <td width="71%">&nbsp;</td>
               </tr><?
                       $UID=$_GET[id];
$gotten = @mysql_query("select * from users where user_id=$UID");
if ($row = @mysql_fetch_assoc($gotten)) {
      $bytes = $row[picture1];
} else {
       $errmsg = "There is no image in the database yet";
       $title = "no database image available";
       }
if ($_REQUEST[gim] == 1) {
       header("Content-type: image/jpeg");
       print $bytes;
       exit ();
       }

                   ?>
                                       <input type="hidden" name="txtMenuID" size="60" value="<?=$row["user_id"]?>">

                             <script language="javascript1.2">
                             editor_generate('txtDescription1');
                       </script>
           <tr>                                                
                 <input type="hidden" name="MAX_FILE_SIZE" value="50000">
                 <td width="30%" class='style9'>Picture 1</td>
                 <td width="70%"><img src=?gim=1 width=144>
<br><input type="file" name="txtPic" size=30>
                 
                       </td>      
           </tr>



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho