2012-06-13 5 views
1

PHP 응용 프로그램 (작동)을 작성하고이를 다른 디렉토리로 옮겼습니다. 그 결과는 위 디렉토리에서 파일을 얻기 위해 필요하지만 파일, 즉 숨겨진 상태로 유지해야합니다PHP XML 오류가 발생했습니다

  • 루트
  • --config
  • --- users.xml 파일을 (권한 600)
  • --lib
  • ---- loginUtil.php

내가 파일 얻는 두 가지 방법을 시도 :

$xml = file_get_contents("../config/users.xml"); 

Which returns the following Error: 

    [13-Jun-2012 08:54:04] PHP Warning: file_get_contents(../config/users.xml) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory in public_html/test/lib/loginUtil.php on line 18 

$xml = simplexml_load_file("../config/users.xml"); 

    which returns 

    [13-Jun-2012 08:56:17] PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: I/O warning : failed to load external entity 

내가 전체 URL을 사용하여 시도하고, 그 작동하지만 (PHP는 URL 요청을하고있다으로) 내가 다음 users.xml에서 파일을 공개해야합니다.

이 문제를 해결하려면 어떻게해야합니까? (당신의 도움을 주셔서 감사합니다)

+0

는 –

+0

작동하지 않았다 권한으로 0644을 사용해보십시오. 나는 이미 777을 시도했지만 그 중 하나는 작동하지 않습니다. – user1453967

+0

포함 된 클래스 등이 아닌 CALLED 파일 (예 : index.php)을 옮겼습니까? – Sliq

답변

1

전체 경로를 설정하는 시도가 아닌 상대

$path = '/var/full/path_dir/file.xml'; 

if(!is_file($path)){ 

    // if this is the is output then you need to check permissions 
    // double check the file exists also. 
    // check the web service can read the file 
    echo "FILE NOT FOUND FOR $path"; 
} 
else{ 
    $xml = file_get_contents($path); 
    echo $xml; 
} 
관련 문제