Download and Write a Graphic

From: Date: Wed, 11 Oct 2000 05:59:32 +0000
Subject: Download and Write a Graphic
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-19514@lists.php.net to get a copy of this message
Greetings! I am trying to download a graphic with either fopen() or file() and then write it to a local file on the server. What I'm trying to do is grab a weather graphic that's updated every 30 minutes. This will eliminate the need for the server to rely on that server being up to display the image and it will also allow the graphic to be displayed on https:// pages without displaying a "This page contains secure and unsecure items" message on SSL pages. Here's what I have now: $url = "http://www.graphics.com/graphic.gif"; $fp = fopen($url, "r"); if(!$fp) { echo "Error: Cannot connect"; } else { $output = fgets($fp, 4096); fclose($fp); } $filename = "/usr/home/inetwor6/www/vhosts/bocaratonchamber.com/graphics/weather/current .gif"; $fd = fopen("$filename", "w+"); fwrite($fd, $fp); I've tried many combinations of the above and imagine one of you has done this and has a snippet solution. Thanks in advance, Dan

« previous php.general (#19514) next »