title: Uploading An Image To A MySQL Database Using A Blob
body: <p>Just to first clarify, I know there are better ways to do this, but I'm determined to experiment. </p>
  
  <p>Basically, I'm trying to grab an image from a form post, then send that into a database <em>MEDIUMBLOB</em> field. </p>
  
  <p>Unfortunately, using my current method, the end result in the database column is always zero bytes.
  <a href="https://i.stack.imgur.com/asE4g.png" rel="nofollow noreferrer">phpMyAdmin Screenshot</a>
  <a href="https://i.stack.imgur.com/asE4g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/asE4g.png" alt="enter image description here"></a></p>
  
  <p>Here is the code for the image upload on the form:</p>
  
  <pre><code>input type="file" name="_imagePost"&gt;
  </code></pre>
  
  <p>Here is the PHP code on the page, I'm using MySQLi :</p>
  
  <pre><code>    if(isset($_POST['_imagePost']))
      {
          $_useImagePost = 1;
          $_imagePost = file_get_contents($_FILES['_imagePost']);
  
          // Open DB Connection
          $_conn = databaseConnect();
  
          $_stmt = $_conn-&gt;prepare("INSERT INTO Question (Question_Type, Question_Text, Question_Answer, Question_UseImage, Question_Image) VALUES (?, ?, ?, ?, ?)");
          $_stmt-&gt;bind_param("sssib", $_typePost, $_textPost, $_answerPost, $_useImagePost, $_null);
          $_stmt-&gt;send_long_data(4,$_imagePost);
          $_stmt-&gt;execute();
  
          // Close DB Connection
          $_conn-&gt;close();
      }
  </code></pre>
  
  <p>What I am unsure of is if "isset($_POST['_imagePost'])" works when the input type is file. </p>
  
  <p>What I am sure of, however, is that the current setup doesn't work at all.</p>