php - readfile function returning file content in non ASCII characters -


when execute following code, image not displayed in browser , rather non ascii symbols , characters displayed instead.few lines follows:

����jfif��6photoshop 3.08bimgqaridey1blfs2krgbsou��icc_profilelcmsmntrrgb xyz �)9acspappl���-lcms desc�^cprt\wtpthbkpt|rxyz�gxyz�bxyz�rtrc�@gtrc�@btrc�@descc2textfbxyz ���-xyz 3�xyz o�8��xyz b����xyz $����curv��c�k�?q4!�)�2;�fqw]�kpz���|�i�}���0����c !$( %2%(,-/0/#484.7./.��c

what doing wrong here?

<?php session_start();  if (isset($_session['logsyscuruser'])) { // logged in $id = $_session['logsyscuruser'];   $imglocation = '/applications/xampp/im/';  include "include/specificproductdb.php"; $data = new specificpro();    $out = $data->select($query, $id, $pid);   $count = count($out);   }  else {   //not logged in header("location: loginsystem/login.php", true, 302); die(); }    ?>  <!doctype html public "-//w3c//dtd html 4.0 transitional//en"  "http://www.w3.org/tr/rec-html40/loose.dtd"> <html>   <head>     <meta content="text/html; charset=utf-8" http-equiv="content-type">      <link rel="stylesheet" href="css/main.css" type="text/css" />     </head> <body> <div id="section"> <div id="header">  <h1>heading</h1> </div>   <p> <?php if($count==0) {     echo "nothing added till now."; }  else {  ($x = $count-1; $x >= 0; $x--)   {     if(strlen($out[$x][0]) == 68)    {     //file detected     $imgpath = $imglocation . $out[$x][0];      // make sure file exists     if(!file_exists($imgpath) || !is_file($imgpath))     {         header('http/1.0 404 not found');         die('the file not exist');     }      $imgdata = substr($out[$x][0],65,3);      // set appropriate content-type     // , provide content-length.     header('content-type: ' . $imgdata);     header('content-length: ' . filesize($imgpath));      // print image data     readfile($imgpath);     }     else    {      header('http/1.0 403 forbidden');     die('fatal error: absurd entry in database media table');    }     echo "<br><br>";     }    }    ?>   </p>      <input type="button" value="add media" onclick="window.location = 'addmedia.php';">      </div>    </body> </html> 


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -