Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP is_dir() returns false on Windows network drive

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?

like image 981
Wes Avatar asked Nov 06 '12 23:11

Wes


1 Answers

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
like image 161
Lawrence Cherone Avatar answered Sep 20 '22 10:09

Lawrence Cherone