PDA

View Full Version : Is transferring data from a .txt file to a .php file possible?


johnnybananas
12-16-2004, 10:41 AM
Here's the problem I'm facing.

I have an (1) external "news.txt" file on my hard drive, and (2) a "newsupdates.php" file residing on my server. When I type new information into my blank news.txt file offline, I then want to be able to upload this text file to my server through ftp and have it automatically update this information on my newsupdates.php file.

For instance, I want the page content at www.johnny.com/newsupdates.php,

to reflect daily changes I make to the news.txt file.

I am using php4. Is this possible?

- Johnny Bananas -

NOTE: That link doesn't work its just an example.

Sayonara
12-16-2004, 11:22 AM
Use fopen() (http://uk.php.net/manual/en/function.fopen.php).

raf
12-16-2004, 11:22 AM
yes, it is possible. and i can imedeately think of four possible ways:
- dayly upload the txt manualy through FTP (always replacing the file from the day before) and just read it in and parse it with file() etc
- dayly upload the file with a form (just a filefield) and then move it so that it replaces the file from the day before --> requires that the file is in a dir where the webserver has write-permission
- automatically ftp the file to it's location (with a CRON or scheduled task that request a PHP. Requires that your local machine is connected to the web + allows ftp-downloads.)
- edit the file directly on the server through a webpage

or use a db instead of a txt ...

bnovc
12-16-2004, 07:28 PM
Set a windows task or cron job to upload it.

(sorry I didn't read all of raf's post originally)