2012-09-10 21 views
2

我正在嘗試使用scandir()來獲取目錄的文件列表。不能從內部網使用scandir

<?php 
function getFileList($directory) { 
    //Get the listing of the files/folders within the directory, place into an array. 
    $files = scandir($directory); 
    //Remove . and .. from the array. 
    unset($files[0]); 
    unset($files[1]); 
    //Reindex array. 
    $files = array_values($files); 

    return $files; 
} 

$directory = '//192.168.1.20/is/Vendors/DavLong/Krames/'; 
    $files = getFileList($directory); 

?> 

使用此代碼從我的本地機器(192.168.1.165)中運行,但當偉大工程時,通過公司內部網(192.168.1.35)我得到以下警告,這讓我的腳本運行運行:

Warning: scandir(//192.168.1.20/is/Vendors/DavLong/Krames/) [function.scandir]: failed to open dir: Invalid argument in C:\Inetpub\wwwroot\DocumentPrint\index.php on line 4 

Warning: scandir() [function.scandir]: (errno 22): Invalid argument in C:\Inetpub\wwwroot\DocumentPrint\index.php on line 4 

Warning: array_values() [function.array-values]: The argument should be an array in C:\Inetpub\wwwroot\DocumentPrint\index.php on line 9 

我可以當使用192.168.1.35框在Windows中運行對話框中,輸入//192.168.1.20/is/Vendors/DavLong/Krames/和它打開Windows資源管理器在適當的位置,使整機能夠找到所請求的地址。

有人可以幫助我解決我在本地和通過企業內部網的問題。提前感謝您提供任何可以解決問題的信息。

+1

你是否檢出過去的線程?它可能有幫助。 http://stackoverflow.com/questions/1153824/php-access-network-path-under-windows –

回答

0

我不知道如何通過網絡閱讀文件夾,但是你不可能映射網絡驅動器,而是嘗試在該驅動器上使用scandir()?

+0

不幸的是,即使將它作爲映射驅動器,它也會返回相同的警告。 – Jeremy1026