title: Image uploading doesn't work
body: <p>So guys.. I want to upload an image to a certain folder name "uploads" and insert the name of that image on database, the problem is that he isn't uploading the image..</p>
  
  <p>So i have this basic <strong>HTML</strong> code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form action="newimage.php" method="POST"&gt;
  
    &lt;div class="row"&gt;
      &lt;div class="col-md-6 col-sm-6 col-xs-12"&gt;
  
        &lt;div class="form-group"&gt;
          &lt;input type="file" name="pic" id="pic"&gt;
        &lt;/div&gt;
  
  
        &lt;button type="submit" class="btn btn-success"&gt;Submit&lt;/button&gt;
      &lt;/div&gt;
  
    &lt;/div&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>And this is my <strong>PHP</strong> page</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;?php
    $mysqli = new mysqli("localhost", "root", "", "homepage");
   
    if (mysqli_connect_errno()) {
      printf("Connect failed: %s\n", mysqli_connect_error());
      exit();
    }
  
    $name = "somethinghere";
  
    #do upload
    $target_dir = "uploads";
    $temp = explode(".", $_FILES["pic"]["name"]);
    $newfilename = $target_dir . '/Foto-' . $name . '.' . end($temp);
  
    if (move_uploaded_file($_FILES['pic']['tmp_name'], $newfilename) ) {
      $productimage = 'Foto-' . $name . '.' . end($temp);
    }
    else
    {
      $productimage = '';
    }
  
  
    $sql = "INSERT INTO galeria_front (image_name) VALUES ('$productimage')";
  
    if ($mysqli-&gt;query($sql) === TRUE) {
        header("Location: galery.php");
    } else {
        echo "Error: " . $sql . "&lt;br&gt;" . $mysqli-&gt;error;
    }
  
    $mysqli-&gt;close();
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>As you can see i have a conection which works, and tried to insert the productimage into the database table but for some reason , it's entering the else{} and making my productimage empty on the database which means the above upload isn't working.</p>
  
  <p>P.S(Pardon me for any bad english)</p>