在PHP中上传示例文件时出错

I am uploading file in PHP using following code.

  $target_dir = "/home/user/uploads/";
  $target_file =  $target_dir .basename($_FILES["fileToUpload"]["name"]);
  $uploadOk = 1;


  if ($_FILES["fileToUpload"]["size"] > 5000000) {
      echo "Sorry, your file is too large.";
      $uploadOk = 0;
  }


  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.";
    }
}

But I am getting the following error:

Sorry, there was an error uploading your file

May I know what is the reason behind this?