title: How to insert Input type="file" as LONGBLOB data type in phpmysql properly with XAMPP Version 1.8.2?
body: <p>So, I have been told that inserting "file" input type cannot be so easy like inputting the string normally. </p>
  
  <p><a href="https://www.codexworld.com/store-retrieve-image-from-database-mysql-php/" rel="nofollow noreferrer">Also, I have seen this website but I think the code is used for different version XAMPP server because it used "mysqli", while my version does not accept mysqli syntax.</a> </p>
  
  <p>Here is my code to do insertion to the MySQL database:</p>
  
  <pre><code>if(isset($_POST['submit'])){
  $pid = mysql_real_escape_string($_POST['productID']);
  $productName = mysql_real_escape_string($_POST['productName']);
  $productImg = mysql_real_escape_string($_POST['productImg']);       **[Possible problem in This Part]**
  
  $insert = mysql_query("INSERT INTO products (productID, productName, productImg) VALUES ('$pid', '$productName', '$productImg')");
  
  if($insert)
  {
      echo 'Successfully added new record.';
  } else {
          echo 'Failed to add new record because '.mysql_error();
         }
  </code></pre>
  
  <p>My HTML form to upload the image looks like this: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post"&gt;
  &lt;table border="1"&gt;
    &lt;tr&gt;
      &lt;b&gt;&lt;td colspan="2"&gt;&lt;h2&gt;Insert new Product&lt;/h2&gt;&lt;/td&gt;&lt;/b&gt;
    &lt;/tr&gt;
    
    &lt;tr&gt;
      &lt;td&gt;Product ID&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="productID"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    
    &lt;tr&gt;
      &lt;td&gt;Product Name:&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="productName" required&gt;&lt;/td&gt;
    &lt;/tr&gt;
    
    &lt;tr&gt;
      &lt;td&gt;Product Image:&lt;/td&gt;
      &lt;td&gt;&lt;input type="File" name="productImg" required&gt;&lt;/td&gt;
    &lt;/tr&gt;
   
   &lt;tr&gt;
      &lt;td colspan="2"&gt;&lt;input style="color:black; font-weight: bolder; margin-left: 110px; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px;" type="submit" name="submit" value="Submit"&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
  &lt;/table&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Based on the website that I have attached I found out that the guy uses this block of code to do image insertion: </p>
  
  <pre><code>if(isset($_POST["submit"])){
  $check = getimagesize($_FILES["image"]["tmp_name"]);
  if($check !== false){
      $image = $_FILES['image']['tmp_name'];
      $imgContent = addslashes(file_get_contents($image));
  </code></pre>
  
  <p>When I implemented this block of code to mine, It got some error and I have no idea why most of the code using ["tmp_name"] this, in their code. Please explain and if possible please do a correction to my code.</p>