2013-02-01 65 views
3

我试图将图像上传到PHP服务器并从那里使用该文档中的图像发送到parse.com:https://parse.com/docs/rest#filesPHP的CHMOD():没有这样的文件或目录

但在解析,我只能看到0个大小的图像。我在想,问题是与文件许可

所以我试图改变文件的权限。

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

但在执行这个我收到以下警告

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

我可以看到在上传文件夹中的文件。而该文件的所有者是www-data。任何指针

PS:而不是绝对路径我也尝试过使用相对路径。

+0

您使用的是哪个版本的PHP并且是safe_mode on? –

回答

2

您正在通过执行'FILE'来锁定脚本文件而不是PATH。

使用'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); 
相关问题