Re: Copy and read a file

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

 



On Fri, 2003-04-18 at 06:04, Miguel Brás wrote:
> Hi gents,
> 
> I wanna copy a file from a webserver to my webserver everytime someone runs
> the script A.
> 
> Someone gave me the following lines for it:
> 
> ******************
> $fp = fopen ("http://www.ivan.ivao.org/whazzup.txt";, "r");
> 
> while (!feof ($fp))
> {
> $buffer = fgets($fp, 10000);
> $fo = fopen ("data_status.txt","a+");
> fputs($fo,$buffer);
> }
> fclose ($fp);
> fclose ($fo);
> 
> ******************
> 
> For sure that this works, but it appends the new file, and i want to delete
> all the old data and write the new one on the begin of the file.
> 
> Any idea for it?
> 
> The other part is that i wanna start on a specific point of the file and
> make a search for a word. If i find the word, it continues to look until
> eof. Then it returns me all the data found. Any help here also?
> 
> Miguel

Change your "a+" in the fopen() call to "w+" and then read this:

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

-- 
Dave Smith
System Programmer, BYU CS Department
GPG Fingerprint: F907 A5C6 17AE C55D CE33  9F05 A829 B63C 99AE 2919

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux