Re: To copy a file from one server to another server in php
| From: | Michael Hulse | Date: | Mon, 02 Jan 2006 08:32:46 +0000 |
| Subject: | Re: To copy a file from one server to another server in php | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-228076@lists.php.net to get a copy of this message | ||
Hello,
On Jan 2, 2006, at 12:27 AM, suma parakala wrote:
Hi Can anyone tell me how can we copy one file from one server to another server using PHP Thanks SumaI use this function to grab mp3's from one server and place them on another (transfers 10mb files rather nicely): function grab_mp3($in, $out) { $remote = fopen($in, 'r'); # Remember to chmod download folder to 777: $local = fopen('test/'.$out, 'w+'); if(!$remote) { // handle failed request here ... echo "Oops!"; } else { while (!feof($remote)) { # Use @ to supress warning messages: @$a .= fread($remote, 8192); } } fwrite($local, $a); fclose($remote); fclose($local); # Bye bye. } You could also use cURL: http://us3.php.net/curl Hth, Cheers, Micky