title: excel file uploading in php
body: <p>i am working on a project in php and trying to upload an excel file to server but it fails every time. My code files are below:   all functions modules are working correctly in newupload.php file given below, but move_uploaded_file function is not working and file is not moving to destination. Please check my code and help please </p>
  
  <pre><code>//this is first page
      //index.php
  
          &lt;!DOCTYPE html&gt;
          &lt;html&gt;
          &lt;body&gt;
  
          &lt;form action="newupload.php" method="post" enctype="multipart/form-data"&gt;
              Select image to upload:
              &lt;input type="file" name="fileToUpload" id="fileToUpload"&gt;
              &lt;input type="submit" value="Upload Image" name="submit"&gt;
          &lt;/form&gt;
  
          &lt;/body&gt;
          &lt;/html&gt;
  
      //second page
      //newupload.php
  
      &lt;?php
      $target_dir = "uploads/";
      $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);//destination
      $uploadOk = 1;
      $FileType = pathinfo($target_file,PATHINFO_EXTENSION);//returns extension of file
      // Check if image file is a actual image or fake image
      if(isset($_POST["submit"])) {
          $check = filesize($_FILES["fileToUpload"]["tmp_name"]);
         }
      // Check if file already exists
      if (file_exists($target_file)) {
          echo "Sorry, file already exists.";
          $uploadOk = 0;
      }
      // Check file size
      if ($_FILES["fileToUpload"]["size"] &gt; 500000) {
          echo "Sorry, your file is too large.";
          $uploadOk = 0;
      }
  //checks whether file is excel or not
      if($FileType != "xlsx" ) {
          echo "Sorry, Excel files are allowed.";
          $uploadOk = 0;
      }
      // Check if $uploadOk is set to 0 by an error
      if ($uploadOk == 0) {
          echo "Sorry, your file was not uploaded.";
      // if everything is ok, try to upload file
      } 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.";// this error arising in my program
          }
      }
      ?&gt;
  </code></pre>
  
  <p>//please help me, Thanks in advance</p>