title: How can I insert an image in a MySQL database using PHP?
body: <p>I am using this form:</p>
  
  <pre><code>&lt;FORM action="testimage1.php" method="post"&gt;
                   &lt;div style="font:bold 10px arial,serif;" &gt;Product Name*&lt;/div&gt;
                   &lt;input type="text" name="myuserName" maxlength="50" /&gt;&lt;br /&gt;
                    &lt;div style="font:bold 10px arial,serif;" &gt;Upload a photo&lt;/div&gt;
                   &lt;input name="uploadimage" type="file" /&gt;&lt;/br&gt;
                   &lt;div style="font:bold 10px arial,serif;"&gt;Product Description:&lt;/div&gt; &lt;input type="text" name="product" value=""&gt;&lt;/br&gt;
                   &lt;input id="submit" type="submit" value="submit" /&gt;&lt;br /&gt;
                   &lt;/form&gt;
  </code></pre>
  
  <p>and in test1.php</p>
  
  <pre><code>require_once("dbconnect.inc.php");  //for database connection                   
      $db_name="thinstrokes";                                     
       $tbl_name="product";
       $db_selected=mysql_select_db("$db_name")or die("cannot select DB");
      // Connect to server and select databse.
      // username and password sent from form 
      $myusername=$_POST['myusername']; 
      $myproduct=$_POST['product'];
      $filename=$_POST['uploadimage'];
  
  $imgData = file_get_contents($filename);
      $size = getimagesize($filename);
      $sql = "INSERT INTO product
      (productname, image_id , image_type ,image, image_size, image_name,productdesc)
      VALUES
      ('$myusername','11', '{$size['mime']}', '{$imgData}', '{$size[3]}', 
       '{$_FILES['userfile']['name']}','$productdesc')";
      $result=mysql_query($sql) or die("error in uploading/*");
  </code></pre>
  
  <p>and getting errors are:-</p>
  
  <p><i>file_get_contents(DSC02945.JPG) [function.file-get-contents]: failed to open stream: No such file or directory in C:\xampp\htdocs\thinstrokes original site\testimage1.php on line 22</p>
  
  <p>Warning: getimagesize(DSC02945.JPG) [function.getimagesize]: failed to open stream: No such file or directory in C:\xampp\htdocs\thinstrokes original site\testimage1.php on line 23</i></p>
  
  <p>how can i correct it..???</p>