Hri*_*shi 5 php permissions file-upload
我试图将图像上传到PHP服务器并从那里将图像发送到parse.com使用此文件:https://parse.com/docs/rest#files
但在解析中,我只能看到大小为0的图像。我认为问题出在文件许可上
因此我尝试更改文件权限。
$target_path = "uploads/";
$img =rand().basename( $_FILES['image']['name']);
$target_path=dirname(__FILE__)."/".$target_path.$img;
print($target_path);
chmod($target_path,0777);
Run Code Online (Sandbox Code Playgroud)
但是在执行此操作时,我收到以下警告
Warning: chmod(): No such file or directory in /var/www/test/new.php on line 15
我可以在上载文件夹中看到该文件。文件的所有者是www-data。任何指针
PS:我尝试使用相对路径代替绝对路径。
您通过执行“ FILE ”来定位脚本文件而不是路径。
在尝试权限验证之前,使用“ 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);
Run Code Online (Sandbox Code Playgroud)