PHP is_dir() returns false on Windows network drive

不打扰是莪最后的温柔 提交于 2019-12-19 17:30:23

问题


I have a network drive mapped to drive letter X:\ going to an external hard drive with the path of "\\X-Drive\Public\Data".

I am using Zend Server with Apache.

My PHP command is simple

$isFolder = is_dir("x:/");
echo($isFolder); //FALSE

Things you should know:

The code:

$isFolder = is_dir("c:/");
echo($isFolder); //TRUE

works as expected.

I am running the Zend Apache service as an administrator user. I know this is working properly because in Task Manager the httpd.exe process shows the correct user.

The drive is indeed mapped. I have tried mapping it with several users, to include the same user that Zend Apache uses to no avail.

I have read every post on this matter that I could find. Every problem I've come across exists either because of user permissions, or a typo. I don't see how my problem fall into either category.

I have also tried:

system('net use X: "\\x-drive\public" password1 /user:username /persistent:no');
$isFolder(is_dir("x:/"));
echo($isFolder); //FALSE

I am running Windows Vista x64, and the production code will run in Windows 7 x64.

What other problems could I be running in to?


回答1:


For network shares you should use UNC names: "//server/share/dir/file.ext" Source

If you use the IP or hostname it should work fine:

$isFolder = is_dir("\\\\NAS\\Main Disk");
var_dump($isFolder); //TRUE

$isFolder = is_dir("//NAS/Main Disk");
var_dump($isFolder); //TRUE

$isFolder = is_dir("N:/Main Disk");
var_dump($isFolder); //FALSE


来源:https://stackoverflow.com/questions/13260991/php-is-dir-returns-false-on-windows-network-drive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!