title: Cannot move uploaded file
body: <p>I've been trying to upload a file to my website. The name is stored in my database. I tried all kinds of path notations:</p>
  <p>../images/products, images/products, /var/www/html/images/products</p>
  <p>But none seem to work. And yes, it is being submitted with POST. I've been thinking that perhaps PHP doesn't have the permissions to write to that location?</p>
  <p>Here you can see my code:</p>
  <pre><code>$imageName = $image['name'];
          $imageTmp = $image['tmp_name'];
          $imgSize = $image['size'];
          $imgError = $image['error'];
  
          $imgExt = explode('.',$imageName);
          $imgActualExt = strtolower(end($imgExt));
  
          $allowedExt = array('jpg', 'jpeg', 'png');
  
          if(in_array($imgActualExt, $allowedExt))
          {
              if($imgError === 0)
              {
                  if($imgSize &lt;= 5000000) #If imgSize is smaller then or equal to 5MB
                  {
                      $imageNewName = uniqid('', true) . &quot;.&quot; . $imgActualExt;
                      $imageDest = &quot;../images/products/&quot; . $imageNewName;
                      if(move_uploaded_file($imageTmp,$imageDest))
                      {
                          $sql = &quot;INSERT INTO Products (name, stock, price, image_name) VALUES (?, ?, ?, ?)&quot;;
                          $stmt = mysqli_stmt_init($conn);
                          if(!mysqli_stmt_prepare($stmt, $sql))
                          {
                              header(&quot;Location: ../dashboard.php?error=sqlerror1&quot;);
                          }
                          else
                          {
                              mysqli_stmt_bind_param($stmt, &quot;ssss&quot;, $name, $stock, $price, $imageNewName);
                              mysqli_stmt_execute($stmt);
                              header(&quot;Location: ../dashboard.php?successWithImage=&quot;.$imageTmp);
                          }
                      }
                      else
                      {
                          header(&quot;Location: ../dashboard.php?error=CouldNotMove&quot;);
                      }
                  }
                  else
                  {
                      header(&quot;Location: ../dashboard.php?error=Size=&quot;.$imgSize);
                  }
              }
              else
              {
                  header(&quot;Location: ../dashboard.php?error=Error:&quot; . $imgError);
              }
          }
          else
          {
              header(&quot;Location: ../dashboard.php?error=FileTypeNotAllowed&quot;);
          }
  </code></pre>