简体   繁体   English

php-chmod():没有这样的文件或目录

[英]php- chmod(): No such file or directory

I was trying to upload an image to a php server and from there send the image to parse.com using this documentation : https://parse.com/docs/rest#files 我试图将图像上传到PHP服务器并从那里将图像发送到parse.com使用此文件: https://parse.com/docs/rest#files

but the in parse , I can see only 0 sized images. 但是在解析中,我只能看到0个大小的图像。 I am thinking that the problem is with file permission 我认为问题是文件许可

so I tried to change the file permission. 所以我试图更改文件权限。

            $target_path = "uploads/";
            $img =rand().basename( $_FILES['image']['name']);
            $target_path=dirname(__FILE__)."/".$target_path.$img;
            print($target_path);
            chmod($target_path,0777);

but while executing this I am getting the following warning 但在执行此操作时,我收到以下警告

Warning: chmod(): No such file or directory in /var/www/test/new.php on line 15

I can see the file in the uploads folder. 我可以在uploads文件夹中看到该文件。 and the owner of the file is www-data. 并且文件的所有者是www-data。 any pointers 任何指针

PS: Instead of absolute path I tried using relative paths also. PS:我尝试使用相对路径而不是绝对路径。

You are targeting the script file and not the PATH by doing ' FILE '. 您通过执行' FILE '来定位脚本文件而不是PATH。

Use ' DIR ' and verify if the folder exist is_dir() before attempting permission verification. 在尝试权限验证之前,请使用“ DIR ”并验证文件夹是否存在is_dir()。

$target_path = "uploads/";
$img =rand().basename( $_FILES['image']['name']);
$target_path=dirname(__DIR__)."/".$target_path.$img;
print($target_path);
chmod($target_path,0777);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM