2014-11-10 7 views
0
-Tried 

에서 전화를 받고 때 리눅스 페도라에 파일/폴더를 삭제 - sudo는 chmod를 -R A +의 RWX는/usr/share/nginx를/uploadedData만들 수 없습니다/PHP 서버

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

  • 합계는/usr/share/nginx를/uploadedData

    [루트 @ localhost를 uploadedData] # 합계는/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 
    } 
    

답변

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

그래서 오류가 표시됩니까? 2 행의 변수 $ file_path가 정의되지 않았습니다.

그리고 pls는 파일을 WWW 사용자에게 시도합니다. PHP safe_mode는 스크립트가 실행되는 동일한 사용자가 소유 한 파일을 요구합니다. 파일은 웹 사용자가 아닌 UID 1000이 소유합니다.

+0

두 번째 줄이 제거되었지만 여전히 동일한 오류가 발생합니다. – Arun

+0

당신은 www 사용자에게 파일을 chown해야합니다. – cari

+0

echo posix_getuid(); echo ('::'); echo'whoami'; echo [ 'name'=> apache [passwd] => x [uid] => 48 [gid] => 48 [gecos] => 아파치 [dir] =>/usr/share/httpd [shell] =>/sbin/nologin) – Arun

0

I 라인 2 코드이

$ file_pathDecoded = base64_decode ($ file_pathDecoded)처럼해야한다고 생각;

+0

이 작업을 수행했지만 여전히 동일한 오류가 발생합니다. – Arun

관련 문제