title: PHP upload image -> Undefined index
body: <p>I'm trying to do a form to upload a image to a folder on the root directory of the domain '/uploads' and the information to a database (doing that after solving this problem). But everytime I try to submit the data, the upload PHP prints this:</p>
  
  <blockquote>
    <p>Array
    (
    )
    files exist</p>
    
    <p>Notice:  Undefined index: profileUpload in [my pc directory to host]/data/db-updates/addAccount.php on line 29</p>
    
    <p>Notice:  Undefined index: profileUpload in [my pc directory to host]/data/db-updates/addAccount.php on line 30</p>
    
    <p>Notice:  Undefined index: profileUpload in [my pc directory to host]/data/db-updates/addAccount.php on line 31</p>
    
    <p>Sorry your file was not uploaded</p>
  </blockquote>
  
  <p>I'm currently developing the website that contains this page on MAMP (mac).</p>
  
  <p>.htaccess </p>
  
  <pre><code>RewriteEngine on
  
  RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
  RewriteRule ^ /%1 [NC,L,R]
  
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteRule ^ %{REQUEST_URI}.php [NC,L]
  
  RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
  RewriteRule ^ /%1 [NC,L,R]
  
  RewriteCond %{REQUEST_FILENAME}.html -f
  RewriteRule ^ %{REQUEST_URI}.html [NC,L]
  
  Header set Access-Control-Allow-Origin "*"
  
  AddType application/vnd.ms-fontobject .eot
  AddType font/ttf .ttf
  </code></pre>
  
  <p>admin-addAccount.php (file with form)</p>
  
  <pre><code>&lt;?php
    //ini_set("display_errors","on");
    //error_reporting(E_ALL);
  
  ?&gt;
  &lt;link rel="stylesheet" type="text/css" href="/data/css/admin-addAccount.css"&gt;
  &lt;link rel="stylesheet" media="screen" href="https://fontlibrary.org/face/beon" type="text/css"/&gt;
  &lt;section class="content"&gt;
    &lt;div class="addAccount_holder"&gt;
      &lt;div class="addAccount_holder_title"&gt;Adicionar Conta&lt;/div&gt;
      &lt;div class="addAccount_holder_content"&gt;
        &lt;form action="/data/db-updates/addAccount.php" enctype="multipart/form-data" method="post"&gt;
          &lt;input type="file" name="profileUpload" id="profileUpload" class="profileUpload" /&gt;
          &lt;label for="profileUpload"&gt;&lt;i class="fas fa-upload"&gt;&lt;/i&gt; Foto de Perfil&lt;/label&gt;&lt;br /&gt;
          &lt;span&gt;Nome&lt;/span&gt;&lt;input name="nome" type="text" required/&gt;&lt;br /&gt;
          &lt;span&gt;Email&lt;/span&gt;&lt;input name="email" type="email" required/&gt;&lt;br /&gt;
          &lt;span&gt;URL&lt;/span&gt;&lt;input name="url" type="text" required/&gt;&lt;br /&gt;
          &lt;span&gt;Instagram&lt;/span&gt;&lt;input name="instagram" type="text" /&gt;&lt;br /&gt;
          &lt;span&gt;Facebook&lt;/span&gt;&lt;input name="facebook" type="text" /&gt;&lt;br /&gt;
          &lt;span&gt;Twitter&lt;/span&gt;&lt;input name="twitter" type="text" /&gt;&lt;br /&gt;
          &lt;span&gt;Telemóvel&lt;/span&gt;&lt;input name="telm" type="text" /&gt;&lt;br /&gt;
          &lt;input type="submit" name="submit" value="Registar"&gt;
        &lt;/form&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p>addAccount.php (file that does the upload and the rest)</p>
  
  <pre><code>&lt;?php
  
  ini_set("display_errors","on");
  error_reporting(E_ALL);
  
  if (TRUE) {
    echo '&lt;pre&gt;';
    print_r($_FILES);
    echo '&lt;pre&gt;';
  }
  
  $ok = TRUE;
  
  // Check if there is an uploaded file.
  if (!array_key_exists('profileUpload', $_FILES) &amp;&amp; !empty($_FILES['profileUpload'])) {
    echo "Sorry, no file seems to be uploaded.";
    $ok = FALSE;
  } else {
    echo "files exist";
  }
  
  $charactersId = '0123456789abcdefghijklmnopqrstuvwxyz';
  $charactersLength = strlen($charactersId);
  $userid = '';
  for ($i = 0; $i &lt; 8; $i++) { $userid .= $charactersId[rand(0, $charactersLength - 1)]; }
  
  $target = "/uploads/";
  $target = $target . 'usrProfile_'.$userid.$_FILES['profileUpload']['type'] ;
  $uploaded_type = $_FILES['profileUpload']['type'];
  $uploaded_size = $_FILES['profileUpload']['size'];
  
  // This is our size condition.
  if ($uploaded_size &gt; 350000) {
    echo "Your file is too large.&lt;br&gt;";
    $ok = FALSE;
  }
  
  //This is our limit file type condition
  if ($uploaded_type =="text/php") {
    echo "No PHP files&lt;br&gt;";
    $ok = FALSE;
  }
  
  // Here we check that $ok was not set to 0 by an error
  if ($ok) {
    echo "Sorry your file was not uploaded";
  }
  // If everything is ok we try to upload it
  else {
    if (move_uploaded_file($_FILES['profileUpload']['tmp_name'], $target)) {
      echo "The file ". basename( $_FILES['profileUpload']['name']). " has been uploaded";
    }
    else {
      echo "Sorry, there was a problem uploading your file.";
    }
  }
  
  ?&gt;
  </code></pre>
  
  <p>I've already searched here on stack overflow and the only solution that i found was including <code>enctype="multipart/form-data"</code> but I've already had that and it keeps showing me the errors.</p>
  
  <p>[edit 1: added names to inputs]</p>