Does anyone know a script that do this: Reads from TXT file available online, and save it on a given dir with a given name. Thanks
could you tell us a bit more are you saying reads a web page or reads a file from a another hosted server
$text = file_get_contents("fileToRead.txt"); Are you using PHP5? Use file_put_contents to save $text. Otherwise look at us3.php.net/fwrite
ssanders, wouldn't that just get the stuff within the .txt file? EDIT: Didn't see the second part, sorry
Hi Guys, What I have right now is a page, that loads some data from MySQL database, and retrieves a TXT file using this code at the header: header("Content-type: ASCII"); header("Content-Disposition: attachment; filename=".$date."_File.txt"); Code (markup): This code makes the user able to download a file like this: 20070823_File.txt for example. But this is dynamic data that changes everyday. I could make a cron and start posting all this data into a mysql database by dates, and then create some similar scripts to download specific data from one given date... but I dont want to do that because it would be an extensive database, and I just want the users to be able to download the last 10 txt files from the previous 10 days. --> So what I really need, is to make a php script, that is called by a cron everyday or something, and that saves the txt file into some folder on my server. My problem is that I don't know how to create a script, that actually saves this txt file into a folder. Any idea ? thanks for any help !
Hi, Try this script by setting a cron job $contents = {data retrieved from mysql db} $newfile = time().".txt"; $folder = "savedfiles"; $path = $folder."\$newfile"; $fp = fopen($path,"w"); fwrite($fp,$contents); PHP: