2014-02-21 45 views
-3

嗨我是新來的PHP,因爲我不知道要解決的警告我正在嘗試獲取文件夾中的文件的名稱。scandir()期望參數1是一個有效的路徑

警告:scandir()期望參數1是有效的路徑。

但是,雖然上傳文件我使用了相同的路徑; 路徑是:store_documents/

這裏不用我非常簡單的代碼:

$dir=opendir("store_documents/"); 
$read_file=scandir($dir); 
echo $read_file; 

回答

2
<? 
$dir = 'store_documents'; 
$files = scandir($dir); 
print_r($files); 

試試這個代碼。

0
<?php 
error_reporting(0); 
$dir="store_documents"; 
[email protected]($dir); 
echo $read_file; 
?> 

@會刪除警告嘗試error_reporting(0);(你不需要兩者)

+0

爲什麼呢?任何一個已經足夠 –

+0

剛剛舉例做到兩者 –

相關問題