RE: problem to open dir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I experienced the same problem some time ago.
Try to use \\remote_computer instead of a mounted drive (G:\).
Also, there is something like a BUG in is_dir(). 
The is_dir function does not return the good value for remote shares. Use !is_file() instead of is_dir().

Make sure your script or the user running the script has access to the remote drive. I use IIS to do this. Don't know for Apache but you must be able to run the apache service with a specific user.


here is a code sample that works for me on paths like //remote_computer/d$/Temp/ : 

		function getChildrenFiles($dir){
		$output = array();
		$files = array();
		if((!is_file($dir))&&($dir_handle = opendir($dir))){
//use !is_file instead of is_dir because of a bug in is_dir with windows shares
			while($file = readdir($dir_handle)){
				if($file !== "." && $file !== ".."){
					$files[] = $file;
				}//if
			}//while
			closedir($dir_handle);
			for($i=0; $i<sizeof($files);$i++){
			
	   				$tmpFile = new FileClass("$dir/".$files[$i]);
					
					if (($tmpFile->isFile())
						&&(isset($this->allowedExtensions))
						&&(sizeof($this->allowedExtensions)>0)
						&&(in_array($tmpFile->getExtension(), $this->allowedExtensions))){
						$output[] = $tmpFile;
					}
					elseif(($tmpFile->isFile())&&((!isset($this->allowedExtensions))||(sizeof($this->allowedExtensions)==0))){
						$output[] = $tmpFile;
					}
					else{
						$tmpFile=NULL;
					}

			}//wfor
		}//if
		else{
			//DEBUG //print("NOT DIR or NOT OPENABLE<br />");
		}

		reset($output);
		return $output;
	}

-----Original Message-----
From: Gryffyn, Trevor [mailto:TGryffyn@xxxxxxxxxxxxxxxxx]
Sent: mardi 30 novembre 2004 15:40
To: php-windows@xxxxxxxxxxxxx
Cc: Mike; Pravin-Kumar
Subject: RE:  problem to open dir


I think \' is going to quote the single-quote too.  Best to quote the
backslashes I guess.  Change all the \ to \\

Also.. Silly question.. But that directory DOES exist, right?  

I assume the is_dir() line is 69 and the opendir() is line 70, correct?

-TG

> -----Original Message-----
> From: Mike [mailto:php@xxxxxxxxxxxx] 
> Sent: Tuesday, November 30, 2004 12:06 AM
> To: 'Pravin-Kumar'; php-windows@xxxxxxxxxxxxx
> Subject: RE:  problem to open dir
> 
> 
> When you set the $dir variable, try doing so with single 
> quotes - the \
> character is used to escape things and might be causing some problems.
> 
> If that makes no sense, it's because I'm falling asleep.
> 
> Good luck.
> 
> -M 
> 
> > -----Original Message-----
> > From: Pravin-Kumar [mailto:pravin@xxxxxxxxxxxx] 
> > Sent: Tuesday, November 30, 2004 12:37 AM
> > To: php-windows@xxxxxxxxxxxxx
> > Subject:  problem to open dir
> > 
> > hi all
> > i am getting some unexpected error while try to read a local dir..
> > it is working on the pc where apache is running ..but same 
> > code not working while trying from other pcs in lan..
> > here is code..
> > $dir="C:\Documents and Settings\pravin\Desktop\abcd2"; if 
> > (is_dir($dir)) {
> >     if ($dh = opendir($dir)) {
> >        while (($file = readdir($dh)) !== false) {
> >           echo "filename: $file : filetype: " . filetype($dir 
> > . $file) ."\n";
> >        }
> >        closedir($dh);
> >    	 }
> > 	}
> > 
> > $dir = dir($source);
> > 
> > 
> > giving error:
> > Warning: dir(C:\Documents and Settings\pravin\Desktop\cdac2): 
> > failed to open dir: Invalid argument in 
> > G:\Vyapar\AdvMgmt\addadvt3.php on line
> > 69
> > 
> > Fatal error: Call to a member function on a non-object in 
> > G:\Vyapar\AdvMgmt\addadvt3.php on line 70

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux