无法上传文件到服务器

Cant upload file to server

我在做一个react项目,就是不知道是后端还是前端有错误,所以试了一下php文件,发现里面有错误,所以有什么建议吗?

选中 php.ini 和 file_uploads=开启

    <?php 

    if ($_SERVER['REQUEST_METHOD'] == 'POST') {

        $target_dir = '/var/www/html/server/uploaded/products_images/';
        $target_file = $target_dir . basename($_FILES['files']['name']);


        if (move_uploaded_file($_FILES['files']['tmp_name'], $target_file)) {
            echo 'The file '. htmlspecialchars( basename( $_FILES['files']['name'])). ' has been uploaded.';
        } else {
            echo 'Sorry, there was an error uploading your file.';
        }

    }



?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form method='post' enctype='multipart/form-data' action='product_create_image_upload.php'>
        <input type='file' multiple accept='image/*' name='files'>
        <input type='submit' value='send'>
    </form>
</body>

</html>

设置products_images目录权限为777

在终端

$ cd /var/www/html/server/uploaded
$ chmod -R 777 products_images