1
我正在處理一個簡單的方法,通過php列出目錄中的所有文件。我有code直接從php.net這樣做,但我似乎無法訪問符號鏈接。當我嘗試訪問符號鏈接(到目錄)時,getcwd()將顯示原始工作目錄。路徑名中的PHP符號鏈接
index1.php就是這個文件。我在arch linux上運行。
ls -lh
的目錄。權限似乎是爲了?
[[email protected] .hiddenVideo]$ pwd
/home/drake/public_html/.hiddenVideo
[[email protected] .hiddenVideo]$ ls -lh
total 224K
-rw-r--r-- 1 drake users 921 Nov 13 20:17 index1.php
-rwxr-xr-x 1 drake users 213K Nov 13 15:19 index.php
drwxr-xr-x 2 drake users 4.0K Nov 13 20:05 testDIR
lrwxrwxrwx 1 drake users 26 Nov 13 14:10 Video -> /media/storage_pool/Video/
PHP代碼段:
<?php
echo "<div>" . getcwd() . "</div>";
chdir('Video');
echo "<div>" . getcwd() . "</div>";
echo "</br>";
//list files
if ($handle = opendir('.')) {
echo "<div>Directory handle: $handle</div>";
echo "<div>Entries:</div>";
while (false !== ($entry = readdir($handle))) {
echo "<div>$entry</div>";
}
closedir($handle);
}
?>
其中產量:
/home/drake/public_html/.hiddenVideo
/home/drake/public_html/.hiddenVideo
Directory handle: Resource id #3
Entries:
..
index.php
.
Video
index1.php
testDIR
沒有人有任何意見或建議?我本來以爲這會工作...
我只是看到你的chdir('視頻');讓我編輯我的答案= P – Manatax
奇怪的是,視頻未被識別爲鏈接... – Drake
請確保您使用完整路徑 – Manatax