title: PHP Undefined index in image upload
body: <p>I am trying to upload an image to be stored in a database on mysql however I keep receiving an error:</p>
  
  <blockquote>
    <p>Notice: Undefined index: profilepic in >[php-path]/tuto>rsignupsubmit.php on line 17</p>
  </blockquote>
  
  <p>There is a simple button upload of type file on a form:</p>
  
  <pre><code>&lt;div class="field"&gt;
      &lt;label&gt;Profile Picture&lt;/label&gt;
      &lt;input class="button" type="file" name="profilepic"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I then have this code on another submit page, I am quite new to PHP however I have searched and searched and cannot find a solution anywhere.</p>
  
  <pre><code>//File upload
  $target_dir = "../img/";
  $newprofilepic = $target_dir . basename($_FILES ["profilepic"]["name"]);
  $uploadOk = 1;
  $imageFileType = strtolower(pathinfo($newprofilepic,PATHINFO_EXTENSION));
  
  $newlocation = mysqli_real_escape_string($conn,$_POST['location']);
  $insertquery = "INSERT INTO tutors(name, username, password, email, mobile, 
  profilepic, location, 
  message)"."VALUES('$newname','$newusername','$newpassword','$newemail', 
  '$newmobile', '$newprofilepic', '$newlocation', '$newmessage')";
  
  $result = mysqli_query($conn, $insertquery) or die(mysqli_error($conn));
  
  
  mysqli_close($conn);
  </code></pre>
  
  <p>Thanks in advance.</p>