开发者

How can i download a file to my server, from another ftp server

I am a realtor/web designer. I am trying to write a script to download a zip file to my server from a ftp server. My website is all in php/mysql. The problem that I am having is that I cannot actually log in to the ftp server. The file is provided through a link that is available开发者_开发技巧 to me, but access to the actual server is not available. Here is the link i have access to.

ftp://1034733:ze3Kt699vy14@idx.living.net/idx_fl_ftp_down/idx_ftmyersbeach_dn/ftmyersbeach_data.zip

php's normal functions for accomplishing this give me a connection error. Php does not have permission to access this server... Any solutions to this problem would be a life saver for me. I am looking to use a cron job to run this script every day so i don't have to physically download this file and upload it to my (godaddy) server, which is my current solution (not a good one, i know!).

Also, I can figure out how to unzip the file myself, as I have done some work with php's zip extension, but any tips for an efficient way to do this would be appreciated as well. I am looking to access a text file inside of the zip archive called "ftmyers_data.txt"


Do you have shell access to the server on which your PHP application runs? If so, you might be able to automate the retrieval using a shell script and the ftp shell command.


Use php_curl

$curl = curl_init();
$fh   = fopen("file.zip", 'w');
curl_setopt($curl, CURLOPT_URL, "ftp://1034733:ze3Kt699vy14@idx.living.net/idx_fl_ftp_down/idx_ftmyersbeach_dn/ftmyersbeach_data.zip");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
fwrite($fh, $result);
fclose($fh);
curl_close($curl);

Easy as pi. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜