Php move\u上传的\u文件在本地主机中工作,但在服务器中不工作

Php move\u上传的\u文件在本地主机中工作,但在服务器中不工作,php,pdo,Php,Pdo,我正在使用move_uploaded_file将我选择的一些文件传输到另一个文件夹。它在我的本地主机上工作,但在我们的服务器上不工作。我不知道为什么。这是我的密码 <?php include('connect.php'); if(isset($_POST['submit'])) { $position = $_POST['position']; $first_name = $_POST['first_name'];

我正在使用move_uploaded_file将我选择的一些文件传输到另一个文件夹。它在我的本地主机上工作,但在我们的服务器上不工作。我不知道为什么。这是我的密码

   <?php
     include('connect.php');
     if(isset($_POST['submit']))
     {
       $position = $_POST['position'];
       $first_name = $_POST['first_name'];
       $last_name = $_POST['last_name'];
       $contact_number = $_POST['contact_number'];
       $email = $_POST['email'];
       $status = 'NO';

       $resume = $_FILES['resume']['name'];
       $resume_tmp = $_FILES['resume']['tmp_name'];
       $ret=explode('.',$_FILES['resume']['name']);
       $file_ext=array_pop($ret);
       $extensions = array("pdf","docx");

       if(in_array($file_ext,$extensions )=== false){
        echo "<script> alert('Unsupported format')</script>";
        echo "<script>window.location='index.php';</script>";
       }
       else{    
            move_uploaded_file($resume_tmp,"resume/$resume");
            $query=$pdo->prepare("INSERT INTO                   applicants(position,first_name,last_name,contact_number,email,resume,status) VALUES (:position,:first_name,:last_name,:contact_number,:email,:resume,:status)");
            $query->bindParam(':position',$position);
            $query->bindParam(':first_name',$first_name);
            $query->bindParam(':last_name',$last_name);
            $query->bindParam(':contact_number',$contact_number);
            $query->bindParam(':email',$email);
            $query->bindParam(':resume',$resume);
            $query->bindParam(':status',$status);
            $query->execute();

            echo "<script> alert('You Successfully Applied to this Job')</script>";
            echo "<script>window.location='index.php';</script>";
      }   
      }
    ?>

首先检查上传目录是否存在。然后将其权限更改为777所有可写

$file = "images";
if(is_dir($file))
{
echo ("$file is a directory");
}
else
{
echo ("$file is not a directory");
}

此问题可以通过将文件夹权限更改为777来解决。 转到文件管理器并选择“更改权限”。 让一切都可以写。
仅此而已。

请使用ini_集(“显示错误”,“1”);ini设置(“显示启动错误”,1);错误报告(-1);开始时将显示您遇到的错误。服务器上是否存在简历目录?我们的服务器上存在简历目录,但文件未上载到该目录警告:移动\u上载的\u文件(resume/file.pdf):无法打开流:在/var/www/site.com/public_html/view.php中权限被拒绝此处是警告代码实际上正在将上载的文件移动到resume目录。由于目录不存在或没有正确的权限,权限被拒绝。