Hello Vincent,

It'a bad way to do so, becouse the default sharing (like c$, d$,
admins$) could be turned off. This code, should work fine, if the
user, under witch php is running have permissions to access target
folder:
$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);

Also, on win32 system you have to use double slashes in path.

VD> Hi,

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

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


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

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

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

VD>             reset($output);
VD>             return $output;
VD>     }

VD> -----Original Message-----
VD> From: Gryffyn, Trevor [mailto:[EMAIL PROTECTED]
VD> Sent: mardi 30 novembre 2004 15:40
VD> To: [EMAIL PROTECTED]
VD> Cc: Mike; Pravin-Kumar
VD> Subject: RE: [PHP-WIN] problem to open dir


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

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

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

VD> -TG

>> -----Original Message-----
>> From: Mike [mailto:[EMAIL PROTECTED] 
>> Sent: Tuesday, November 30, 2004 12:06 AM
>> To: 'Pravin-Kumar'; [EMAIL PROTECTED]
>> Subject: RE: [PHP-WIN] 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:[EMAIL PROTECTED] 
>> > Sent: Tuesday, November 30, 2004 12:37 AM
>> > To: [EMAIL PROTECTED]
>> > Subject: [PHP-WIN] 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




-- 
Best regards,
 re_action                            mailto:[EMAIL PROTECTED]

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

Reply via email to