0

Code for uploading in the blob :

mysql_connect('localhost','root','');
mysql_select_db("dtbase");
$file = $_FILES['logo']['tmp_name'];
echo $file;
$imgData =addslashes (file_get_contents($_FILES['logo']['tmp_name']));
$sql="insert into tab1(coname,date,volume,num,eissn,jname,info1,info2,section,logo)values('$coname','$date','$volume','$num','$eissn','$jname','$info1','$info2','$section','{$imgData}')";
$rs=mysql_query($sql);

Code for retrieving:

    $image = mysql_query("SELECT * FRom tab1 WHERE coname='$coname'");
    $im = mysql_fetch_assoc($image);
    $img = $im['logo'];

Using $img to show the image:

<img src="$img" />

The image does not appear on the web page.

tshepang
  • 12,111
  • 21
  • 91
  • 136
  • Try ussing base64 encode – Hackerman Apr 03 '14 at 18:36
  • Images aren't typically inline (in the HTML). Images in the HTML should be links. When the client requests an image from your web server (by full URL like `http://example.com/images/logo.jpg`), then you serve it up in the raw, with the proper mime type header. This keeps the HTML page small and snappy, and images can be downloaded in the web browser in parallel. – Marcus Adams Apr 03 '14 at 18:43
  • possible duplicate of [I need my PHP page to show my BLOB image from mysql database](http://stackoverflow.com/questions/13225726/i-need-my-php-page-to-show-my-blob-image-from-mysql-database) – i'm PosSible Apr 04 '14 at 08:53

1 Answers1

0

Try this:

echo '<img src="data:image/jpeg;base64,'.base64_encode($im['logo']).'" alt="photo"><br>';
Hackerman
  • 12,139
  • 2
  • 34
  • 45