Re: Dwonloading a file

From: Date: Wed, 18 May 2005 12:09:47 +0000
Subject: Re: Dwonloading a file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-215457@lists.php.net to get a copy of this message
Brian Dunning wrote:
I need to write a cron job that retrieves a zipped XML file via FTP, unzips it, and then imports the XML into MySQL. I haven't done any of these three specific functions yet. Before I tear my hair out on each of these functions, can anyone point me to a simple example of any or all three?
Download a file : use the 'wget' program if its available on your system. Since you mentioned cron, I assume you are working on linux/unix or similar. If wget is not available, try links/lynx. If those aren't available either, then you can use any of the HTTP classes, such as HTTP_Client (from pear) or my favorite snoopy.sf.net. If your PHP install is bundled with curl, you can also use the curl functions (http://www.php.net/curl) Unzip a file : http://www.php.net/manual/en/ref.zip.php (example is right there in the manual entry) XML: If you are on PHP5, then use simplexml, otherwise, use the regular xml functions. Plenty of examples and tutorials on the internet. Google is your friend. Import into MySQL : just use the mysql command line client if its available to you. mysql -u username -ppassword databasename < file.sql If it is not, use the regular mysql functions to submit queries (mysql_connect, mysql_select_db, and mysql_query). Regards, Burhan

« previous php.general (#215457) next »