title: Upload with PHP
body: <p>I'm creating a website, and I have a form to add a new post. I'm using an iFrame instead of ajax for a full support on IE (Ok, I know that IE is the most hated and one of the worst browser, but some noobs are using it). Basically, when I submit the form, it gives me an internal error (500).
  Here is my form:</p>
  
  <pre><code>&lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionic/1.3.2/css/ionic.min.css"&gt;
  &lt;script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;form enctype="multipart/form-data" class="form" id="form" action="./addPost.php" method="POST"&gt;
           &lt;div class="list"&gt;
            &lt;label class="item item-input"&gt;
              &lt;input type="text" placeholder="Title" class="AddPosttitle" name="title"&gt;
            &lt;/label&gt;
            &lt;label class="item item-input"&gt;
              &lt;input class="description" type="text" placeholder="Simple Description (max 60 caracters)" maxlength="60" name="description"&gt;
            &lt;/label&gt;
            &lt;label class="item item-input"&gt;
              &lt;div&gt;
                  &lt;span id='button_upload'&gt;Image : &lt;/span&gt;
                  &lt;input type='file' class="img" name="img"&gt;
              &lt;/div&gt;
            &lt;/label&gt;
            &lt;label class="item item-input"&gt;
              &lt;textarea placeholder="Full description" class="full" name="full"&gt;&lt;/textarea&gt;
            &lt;/label&gt;
              &lt;div class="padding"&gt;
                &lt;button class="button button-block button-positive submit-btn" type="submit"&gt;
                 Submit
              &lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/form&gt;
      &lt;style type="text/css"&gt;
          .form {
              background: #FFF;
  
          }
      &lt;/style&gt;
      &lt;?php
      if (!empty($_GET['error'])){
          ?&gt;
          &lt;script type="text/javascript"&gt;
              function findGetParameter(parameterName) {
                  var result = null,
                      tmp = [];
                  var items = location.search.substr(1).split("&amp;");
                  for (var index = 0; index &lt; items.length; index++) {
                      tmp = items[index].split("=");
                      if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
                  }
                  return result;
              }
              alert(findGetParameter("error"));
          &lt;/script&gt;&lt;?php
      }
      ?&gt;
  </code></pre>
  
  <p>I'm using the Ionic library, just because I love some components, but anyway, this is my <code>addPost.php</code> file :</p>
  
  <pre><code>&lt;?php
  try
  {
     $db = new PDO('mysql:host=something;dbname=someDB;charset=utf8', 'ID', 'LOL');
  }
  catch(Exception $e)
  {
     die('Erreur : '.$e-&gt;getMessage());
  }
  
  $post = $_POST;
  $img = base64_encode(file_get_contents($_FILES['img']['tmp_name']));
  $title = addslashes($post['title']);
  $description = addslashes($post['description']);
  $fullDesc = addslashes($post['full']);
  // if (!empty($title) &amp; !empty($description) &amp; !empty($fullDesc) &amp; !empty($img)) {
  
  // }
  // else {
  //  // header("Location: form.php?error=Fill the form!");
  // }
  
  $sql = "INSERT INTO posts (title, description, img, fullDesc, likes) VALUES ('$title', '$description', hextoraw('$img')', '$fullDesc', 0)";
  $db-&gt;exec($sql);
      // header("Access-Control-Allow-Origin: *");
  header("Location: form.php?error=$sql");
  </code></pre>
  
  <p>I don't know why there is an error. I think that it comes from the image, but I'm not sure. I'm still trying for an eventual solution, I'll edit my question if I find something (just to let you know!)</p>