title: Uploading a CSV file to a server
body: <p>I am trying to upload a CSV file to a server with a form but I keep getting a error. Would anyone be able to tell me why the file does not want to upload. </p>
  
  <p>HTML code:</p>
  
  <pre><code>        &lt;form action="upload.php" method="post" enctype="multipart/form-data"&gt;
              Select CSV file to upload
              &lt;input type="file" accept=".csv"&gt;
              &lt;input type="submit" value="Upload File" name="submit"&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>PHP code:</p>
  
  <pre><code>&lt;?php
  $target_dir = "uploads/";
  $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
  $fileType = pathinfo($target_file,PATHINFO_EXTENSION);
  
  // Allow certain file formats
  if($fileType != "csv" ) {
      echo "Sorry, only CSV files are allowed. ";
  }
  else {
      if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
          echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
      } else {
          echo "Sorry, there was an error uploading your file.";
      }
  ?&gt;
  </code></pre>