title: Problem using AJAX to import image from MySQL blob into HTML file input type
body: <p>The title sounds confusing so first I'll elaborate. I have a website that among other things allows the users to upload pictures from their phones which go to a MySQL database and are stored in a blob format which works fine. I also have a button that runs an AJAX function which allows the user to import information from said MySQL database and then return it to the same HTML fields (continue where they left off kind of thing). This AJAX function works for everything but the "file" HTML input field type which I use for the pictures.</p>
  
  <p>To get the file data into MySQL I use <code>addslashes(file_get_contents($image));</code> which I'm guessing I have to undo to be able to put it back in the file input field. If that is the case I don't know how to do it. My guess is that the file data is stored in the HTML input field type in one format and in the MySQL in another, but I'm not even sure of that let alone how to fix that if that indeed is the issue.</p>
  
  <p>Here's a few various bits if they help.</p>
  
  <p>HTML / AJAX:</p>
  
  <pre><code>&lt;button type="button" id = 'ajaxButton' onClick = 'imAnAjaxFunction()';&gt;TEST&lt;/button&gt;
  
  &lt;label for="Image1"&gt; Picture 01: &lt;/label&gt;
  &lt;input type="file" id="Image1" name="Image1" value="Image1" 
  
  &lt;script&gt;
  function imAnAjaxFunction()
  {   
  var val1 = $('#Serial').val(); //
  var request = $.ajax({
      url: 'import.php',
      type: 'get',
      data: { Serial: val1 }, //
      dataType: 'html'
  });
  
  request.done( function ( data ) {
      //alert(data);
  });
  
  request.fail( function ( jqXHR, textStatus) {
      console.log( 'Sorry: ' + textStatus );
  });
  
  var val1 = $('#Serial').val(); //
  $.ajax
  ({
      url: 'import.php',
      type: 'get',
      dataType: 'JSON',
      data: { Serial: val1 }, //
      success: function(response)
      {
          var len = response.length;
          for(var i=0; i&lt;len; i++)
          {
              document.getElementById('DateSet').value = response[i].DateSet;
              document.getElementById('JobName').value = response[i].JobName;
              document.getElementById('Image1').value = response[i].Image1;
          }
      }
  })
  
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>insert.php most of it I don't think is relevent</p>
  
  <pre><code>$image = $_FILES['Image1']['tmp_name'];
  $imagetmp=addslashes(file_get_contents($image));
  </code></pre>
  
  <p>import.php</p>
  
  <pre><code>&lt;?php
  ob_start();
  
  $servername = "";
  $username = "";
  $password = "";
  $dbname = "";
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  } 
  
  $sql = "SELECT * FROM setcrewreport WHERE Serial = '$_GET[Serial]'";
  
  $result = $conn-&gt;query($sql); //query
  
  if ($result-&gt;num_rows &gt; 0) 
  {
  // output data of each row
  while($row = $result-&gt;fetch_assoc())
  {
      $Serial = $row['Serial'];
      $DateSet = $row['DateSet'];
      $JobName = $row['JobName'];
      $Image1   = $row['Image1'];
  
      $return_arr[] = array("Serial" =&gt; $Serial,
                            "DateSet" =&gt; $DateSet,
                            "JobName" =&gt; $JobName,
                            "Image1" =&gt; $Image1);
  }
  ob_end_clean();
  // Encoding array in JSON format
  echo json_encode($return_arr);
  }
  else
  {
  echo "0 results";
  }
  
  $conn-&gt;close();
  ?&gt;
  </code></pre>
  
  <p>How close is this to parameterizing the SQL statement?</p>
  
  <pre><code>$sql = $mysqli-&gt;prepare("SELECT * FROM setcrewreport WHERE Serial = ?");
  $sql -&gt;bind_param("si", '$_GET[Serial]');
  </code></pre>