[英]PHP readdir() and opendir() working locally but not working on live server
我得到了以下錯誤,所以改變了
opendir(http://test.myserv.com/Optfolder/upload/upload)
[function.opendir]: failed to open dir: not implemented
所以更改為file_get_contents($ dir)
但接下來我得到了這個錯誤
readdir(): supplied argument is not a valid Directory resource
我該怎么辦?
我使用下面的代碼來讀取文件夾圖像是否有任何選項的opendir和readdir所以ic使用它們為我的目的?
在$ dir中,我得到了像http://testserv.com/optfolder/upload這樣的完整路徑
$dir = opendir($dir);
while ($file = readdir($dir)) {
if (preg_match("/.png/",$file) || preg_match("/.jpg/",$file) || preg_match("/.gif/",$file) ) {
$string[] = $file;
}
}
opendir()
不能在URL上使用,因為它打開了一個相對於文件系統的目錄。 這也是警告的可能重復:打開目錄:未實現 。
readdir()
在定位目錄方面與opendir()
完全相同。
請查看文檔http://php.net/manual/en/function.opendir.php以完全理解它。
您不能在HTTP網址上使用opendir()
。 您需要指定相對目錄路徑。 見opendir
試試這個:
file_get_contents('http://testserv.com/optfolder/upload');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.