Pb with fopen and a file stored on a Network drive... 
Author Message
 Pb with fopen and a file stored on a Network drive...

Hi all,

I'm working with PHP and Apache on NT.
Everything is in the title, I'd like to get data from a file which is stored
on a Network Drive.
I tried fopen, but it didn't work and that's normal I think.
Does anybody knows how to solve this problem? Another thing is that it is
not possible for me to install
a ftp server for example on the other pc.

Tanks a lot.



Tue, 26 Apr 2005 01:06:15 GMT  
 Pb with fopen and a file stored on a Network drive...

says...

Quote:
> Hi all,

> I'm working with PHP and Apache on NT.
> Everything is in the title, I'd like to get data from a file which is stored
> on a Network Drive.
> I tried fopen, but it didn't work and that's normal I think.
> Does anybody knows how to solve this problem? Another thing is that it is
> not possible for me to install
> a ftp server for example on the other pc.

Can't you map a networkdrive?


Tue, 26 Apr 2005 02:22:10 GMT  
 Pb with fopen and a file stored on a Network drive...


Quote:
> Hi all,

> I'm working with PHP and Apache on NT.
> Everything is in the title, I'd like to get data from a file which is
stored
> on a Network Drive.
> I tried fopen, but it didn't work and that's normal I think.
> Does anybody knows how to solve this problem? Another thing is that it is
> not possible for me to install
> a ftp server for example on the other pc.

> Tanks a lot.

The problem is that the php is running under apache, which runs as your PC's
"system" account by default. For security reasons, the system account does
not have permission to access to network rescources by default.

You may have to change the user account that apache runs under and then
explicitly give that user permission to access the files on your network
drive.

I can't remember exactly how to set that on NT but if you go to the services
applet in the control panel and locate the apache service, somewhere you
will be able to set the user the service runs as. You will find that it is
probable set to "system" which as I mentioned, does not have permission to
access the network drive.

Change it to "apache" (or whatever) and then give that user permission to
access the files on the network drive.

Hope this helps



Tue, 26 Apr 2005 04:11:08 GMT  
 Pb with fopen and a file stored on a Network drive...
It worked, thanks a lot. With fopen I got the file pointer (basically I had
Resource#3 as a result).
But with a simple code like that I got the data:

$fichier = "E:\\AN_PIK\\PREISE\\RMP_o_PI.TXT";
if (file_exists($fichier)){
     echo "File exists";
     $fp = fopen($fichier,r);

      while(!feof($fp)) {
           $temp = fgets($fp,128);
             echo $temp;
  } }
else
     {
       echo "File doesn't exists";
       exit();
     }

But there is a new problem. My file seems to be too big. I have only a part
of the file data.
Is it fopen which is limited?



Tue, 26 Apr 2005 18:14:35 GMT  
 Pb with fopen and a file stored on a Network drive...


Quote:
> It worked, thanks a lot. With fopen I got the file pointer (basically I
had
> Resource#3 as a result).
> But with a simple code like that I got the data:

> $fichier = "E:\\AN_PIK\\PREISE\\RMP_o_PI.TXT";
> if (file_exists($fichier)){
>      echo "File exists";
>      $fp = fopen($fichier,r);

>       while(!feof($fp)) {
>            $temp = fgets($fp,128);
>              echo $temp;
>   } }
> else
>      {
>        echo "File doesn't exists";
>        exit();
>      }

> But there is a new problem. My file seems to be too big. I have only a
part
> of the file data.
> Is it fopen which is limited?

In this line:
$temp = fgets($fp,128);
you are only reading the first 128 bytes of each line. Try increasing that
number to say 1024 or more.

http://www.php.net/manual/en/function.fgets.php



Wed, 27 Apr 2005 13:46:38 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Copy file from network drive to local drive?

2. Copy file from network drive?

3. Opening files on a network drive.

4. PHP files don't work in Windows network drive

5. Accessing a file in a network drive (python under win32)

6. MS-Sql Extended Stored Procedures in PB

7. Storing the complete contents of the drive to a collection

8. PB/CC's LPRINT and Network Queues

9. Using $fopen to write to variable files

10. problem with fopen and the file size.

11. pb with proble-file and dot file

12. Can't connect to library across mapped network drive

 

 
Powered by phpBB® Forum Software