从php服务器获取调用时,无法在Linux Fedora上创建/删除文件/文件夹

时间:2014-11-10 11:28:35

标签: php linux fedora

-Tried 

- sudo chmod -R a + rwx / usr / share / nginx / uploadedData

  • sudo chmod -R 0777 / usr / share / nginx / uploadedData

  • stat / usr / share / nginx / uploadedData

    [root @ localhost uploadedData] #stat / usr / share / nginx / uploadedData文件:'/ usr / share / nginx / uploadedData'       大小:4096块:8 IO块:4096目录     设备:fd02h / 64770d Inode:528513链接:2     访问:(0777 / drwxrwxrwx)Uid:(1000 / asingh)Gid:(1000 / asingh)     上下文:unconfined_u:object_r:usr_t:s0     访问时间:2014-11-10 16:38:44.723660912 +0530     修改时间:2014-11-10 20:32:33.076960484 +0530     更改:2014-11-10 16:38:44.723660912 +0530      出生: -

    //但仍然是我的PHP代码

    $file_pathDecoded='/usr/share/nginx/uplodedData';
    $filename=$file_pathDecoded.'/test.txt';
    if (is_file($filename)) {
    
       chmod($filename, 0777);
    
       if (unlink($filename)) {
          echo 'File deleted';
       } else {
          echo 'Cannot remove that file';//results this
       }
    
    } else {
      echo 'File does not exist';
    }
    
    if (!mkdir($file_pathDecoded.'/newfolder', 0777, TRUE)) {
        echo('Failed to create folders...');//results this
    }
    

2 个答案:

答案 0 :(得分:0)

$file_pathDecoded='/usr/share/nginx/uplodedData';
$file_pathDecoded=base64_decode($file_path);

所以你看错了? 第2行中的变量$ file_path未定义。

并尝试将文件chown给WWW用户。 PHP safe_mode要求该文件由运行脚本的同一用户拥有。 您的文件归UID 1000所有,UID 1000似乎不是网络用户。

答案 1 :(得分:0)

我认为第2行的代码应该是这样的

  

$ file_pathDecoded = BASE64_DECODE($ file_pathDecoded);