无法在 Linux Fedora 上创建/删除文件/文件夹,当收到来自 php 服务器的调用时


Unable to create/ delete file/folder on Linux Fedora when getting call from php server

-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

    File: '/usr/share/nginx/uploadedData' 大小: 4096 块: 8 IO 块: 4096 目录 设备: fd02h/64770d 索引节点: 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
    }
    
$file_pathDecoded='/usr/share/nginx/uplodedData';
$file_pathDecoded=base64_decode($file_path);

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

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

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

$file_pathDecoded=base64_decode($file_pathDecoded(;