View Full Version : Error: "failed to open dir: No error" with opendir on network drive

01-08-2010, 04:25 PM
I'm trying to open a network drive, but am getting the error "failed to open dir: No error"

Here is my code:

// Parameters to map network drive
$drive = "Z";
$path = "\\server\share";
$user = "domain\user";
$pass = "pass";

// Map the drive
system("net use ".$drive.": \"".$path."\" ".$pass." /user:".$user." /persistent:no>nul 2>&1");

// Open folder
$dir = opendir("Z:\\") or die('Unable to open '.$path.);

I can run the opendir with C: and open a local folder without any issues, but attempting to access the Z: gives the error. I figure it's an authentication issue, so I've gone to the server and made sure that the "domain/user" I'm using has full permissions for that share, but I still get the error.

Do I need to add more permissions elsewhere or is this a different issue?

I also ran the net use command in a windows cmd prompt to make sure there were no bugs there, it ran fine. Both computers are running XP Pro and I'm coding on Xampp 1.7.2.

Any help would be much appreciated.

01-08-2010, 04:49 PM
this seems to be a common issue with on common fix.

I'm wondering if it might have something to do with the auth type used by windows file sharing. I assume that you can access the share via the local system?

01-08-2010, 04:53 PM
Yes I can open the share locally and have full permissions to it.

01-08-2010, 04:54 PM
maybe just for testing purposes try removing all permissions on the share, so that it requires no login, then try again and see what happens. this might give us a better idea of what the issue could be.

01-08-2010, 05:12 PM
Ok, I've tried giving everyone full control and I've tried removing the users and everyone from the permissions tab. Same error. Also tried adding my domain/user to the normal security tab with full control just in case. Same error both with and without users in the permissions tab.

01-08-2010, 08:33 PM
I've rigged up a temporary work around for now... Since the main purpose of my connection was to store data from some files and then archive the files. I've created a simple batch script that copies the files from the network share to a folder in the webserver and then archives the files on the share. Now I can just work with the files that are copies over and delete them as I finish pulling the data I need. End result is the same as what I wanted, although the method is far less elegant...