fopen() getting failed message

Hi all,

When i trying to fopen() a file which saving in a window 2000 server , it returns a message “Warning: fopen(\192.168.78.2\country\COUNTRY.TXT): failed to open stream: Permission denied in C:\wamp\www\WebForm\routeTable\changeRoute.php”
;
But i can open the file directly if via window browser, so i’m not understand why it saying Permission denied, someone knows why? Thank you

[php]

$file_handle = fopen(’\\192.168.78.2\country\COUNTRY.TXT’,“r”);

if (is_readable($file_handle)) {
echo ‘The file is readable’;
} else {
echo ‘The file is not readable’;
}

[/php]

change this:

fopen(\\192.168.78.2\country\COUNTRY.TXT):

to the path of the file like so:
[php]fopen(’/PUT/YOUR/PATH/TO/THE/FILE/HERE/country.txt’, …[/php]

Hope that helps,
Red :wink:

Hi Red,

Thank you for the reply , i have changed the codes as below , but i’m still getting the same error message
failed to open stream: Permission denied in C:\wamp\www… ; Additional information , the COUNTRY.TXT file is locating in a Windows 2000 server shared folder ; In earlier , i confused the problem is relating the security/user right/permission from the windows 2000 server shared folder , but i can get the file content using Excel VBA (with the same computer :o) , do you have any idea? Thanks 8)

[php]

<?php $path = '//windows2000server/dir1/dir2/dir3/COUNTRY.TXT'; # open file $file_handle = fopen($path,'r'); if (is_readable($file_handle)) { echo 'The file is readable'; } else { echo 'The file is not readable'; } ?>

[/php]

Hi Red ,

The Permission denied error has been fixed , but now i think my local pc (installed WAMP) can’t read/connect the network drive (e.g Z:) :frowning:

[php]$file_handle = “Z:/”;

if( is_dir($file_handle)){ echo ‘success’; }[/php]

But if i change to $file_handle=“C:/”; , page displaying success

i have google a solution (add RestrictNullSessAccess=0 registery on my local pc.) , but still not works

Thanks
Brgds/Brandon Chau

Hi all,

Below solution works , thanks 8)

Brgds/Brandon Chau

Sponsor our Newsletter | Privacy Policy | Terms of Service