title: How to convert jpg image to proper blob data type using php
body: <pre><code>&lt;?php
  $file_name = $_FILES['files']['name'];
  $tmp_name  = $_FILES['files']['tmp_name'];
  $file_size = $_FILES['files']['size'];
  $file_type = $_FILES['files']['type'];
  
  // The codes written above work fine and have proper information.
  
  $fp = fopen($tmp_name, 'r'); // This one crashes.
  $file_content = fread($fp, $file_size) or die("Error: cannot read file");
  $file_content = mysql_real_escape_string($file_content) or die("Error: cannot read file");
  fclose($fp);
  
  ....
  </code></pre>
  
  <p>I'm a newbie to PHP stuff. I'm trying to store a jpg image as blob in a database but terribly struggling with it :( I tried many tutorials and read documents but still no luck. Any suggestions or tutorials that might help me out..?</p>