2011-03-10 32 views
0

我正在嘗試讀取Linux下/ var/www/myDir下的.conf文件。.conf通過php找不到

這是它說找不到文件的代碼

$confFile = "vhost.conf"; 
if (file_exists($confFile)) { 
    echo "The file $filename exists"; 
} else { 
    echo "The file $filename does not exist"; 
} 

。任何想法,爲什麼>

感謝 讓

回答

4

給的完整路徑

$confFile = "/var/www/myDir/vhost.conf"; 
+0

硬luck..still顯示未找到 – X10nD 2011-03-10 11:36:54

+0

@Jean:哼哼..你如何得到_not found_消息它應該是'檔案存在'或'文件不存在' – 2011-03-10 11:46:35

1

是你的腳本在同一路徑執行?否則請嘗試使用完整路徑

if (file_exists('/var/www/myDir'. $confFile)) { 

...

1

嘗試使用絕對路徑,像這樣:

 
$confFile = $_SERVER['DOCUMENT_ROOT'] . "/vhost.conf"; 
if (file_exists($confFile)) { 
    echo "The file $filename exists"; 
} else { 
    echo "The file $filename does not exist"; 
} 

或者,也許這樣的:

 
$confFile = "/var/www/myDir/vhost.conf"; 
if (file_exists($confFile)) { 
    echo "The file $filename exists"; 
} else { 
    echo "The file $filename does not exist"; 
} 
+0

仍然沒有找到.. – X10nD 2011-03-10 11:21:04

+0

該死的!嘗試給你的'myDir'全局讀/寫權限用於測試目的?如果可行,請嘗試不同的權限組合,以獲得您所需的安全性和功能。這是一個長鏡頭,但它可能工作:-) – Bojangles 2011-03-10 17:13:33