Home > Archive > PHP on Windows > November 2004 > RE: [PHP-WIN] problem to open dir
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
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:pravin@ncb.ernet.in]
> Sent: Tuesday, November 30, 2004 12:37 AM
> To: php-windows@lists.php.net
> 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
>
>
>
>
> ---------
> Experience is what you get when you didn't get what you wanted.
> ---------
> Regards
> Pravin Kumar
> Technical Associate, CDAC, 68, E-City, Bangalore, 560100.
> Registered Linux user #365056; Ph. +91 80 28523300 Extn:2103
> http://geocities.com/pravin_suman/
> http://pravindeo.blogspot.com
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
| |
| Pravin-Kumar 2004-11-30, 3:56 am |
|
hi mike!
$source='F:\cdac2';
echo $source;
if(is_dir($source)){echo "it is a dir.";}
else{echo "it is not a dir..";}
i had tried ur suggestion .. not working dude :(
see i had one more thing .. it says "it is not a dir.."
please help me list...........
---------
Regards
Pravin Kumar
On Tue, 30 Nov 2004, Mike wrote:
> 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
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
| |
| Armando 2004-11-30, 3:56 am |
| Try changing your $dir variable to:
$dir="C:\\Documents and Settings\\pravin\\Desktop\\abcd2";
Failing that, try using the Documents and Settings shortname:
$dir="C:\Docume~1\pravin\Desktop\abcd2";
Or:
$dir="C:\\Docume~1\\pravin\\Desktop\\abcd2";
If none of these work, perhaps also try them and replace the double
quotes that enclose the string to single quotes.
I ran into a lot of issues myself when trying to access the windows
filesystem through PHP when using just single backslashes in my path
variables because, as Mike noted, the \ is typically used to escape
characters. In that case when PHP parses your $dir variable, it could be
stripping out the \ thinking they are escaping the next characters. As
soon as I used the double backslashes in my $dir variables on my own
pages, everything worked fine. Mind you, I then got annoyed with some
other Windows related issues so blew away my development box and put
Linux on it instead :-) But I digress...
Cheers.
Armando
-----Original Message-----
From: Mike [mailto:php@crazyted.com]
Sent: November 29, 2004 11:06 PM
To: 'Pravin-Kumar'; php-windows@lists.php.net
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:pravin@ncb.ernet.in]
> Sent: Tuesday, November 30, 2004 12:37 AM
> To: php-windows@lists.php.net
> 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
>
>
>
>
> ---------
> Experience is what you get when you didn't get what you wanted.
> ---------
> Regards
> Pravin Kumar
> Technical Associate, CDAC, 68, E-City, Bangalore, 560100. Registered
> Linux user #365056; Ph. +91 80 28523300 Extn:2103
> http://geocities.com/pravin_suman/
> http://pravindeo.blogspot.com
>
> --
> 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
| |
| Pravin-Kumar 2004-11-30, 9:03 am |
| hi list!
$dest='F:/vyapar-2/test/cdaci'; or
$dest='F:\vyapar-2\test\cdaci'; or
$dest='F:\\vyapar-2\\test\\cdaci'; or
$dh = opendir($dest);
$a=dir($dest);
the above code giving following problem on apache 1.3 on windows
Warning: opendir(F:/vyapar-2/test/cdaci): failed to open dir: Invalid
argument in G:\Vyapar-2.0\test\1.php on line 10
Warning: dir(F:/vyapar-2/test/cdaci): failed to open dir: Invalid argument
in G:\Vyapar-2.0\test\1.php on line 11
--
Nothing is working i had tried \\ , /, "double quot", 'single quot'
---------
Regards
Pravin Kumar
On Tue, 30 Nov 2004, Mike wrote:
> 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
>
>
| |
| Luis Moreira 2004-11-30, 9:03 am |
| Remove the double quotes.
$dh = opendir('F:/vyapar-2/test/cdaci');
Pravin-Kumar wrote:
>hi list!
>
> $dest='F:/vyapar-2/test/cdaci'; or
> $dest='F:\vyapar-2\test\cdaci'; or
> $dest='F:\\vyapar-2\\test\\cdaci'; or
> $dh = opendir($dest);
> $a=dir($dest);
>
>the above code giving following problem on apache 1.3 on windows
>
>Warning: opendir(F:/vyapar-2/test/cdaci): failed to open dir: Invalid
>argument in G:\Vyapar-2.0\test\1.php on line 10
>
>Warning: dir(F:/vyapar-2/test/cdaci): failed to open dir: Invalid argument
>in G:\Vyapar-2.0\test\1.php on line 11
>
>--
>Nothing is working i had tried \\ , /, "double quot", 'single quot'
>
>---------
>Regards
>Pravin Kumar
>
>On Tue, 30 Nov 2004, Mike wrote:
>
>
>
>
>
>
|
|
|
|
|