This script has saved me tons of time in uploading setting up a mirror and would like to help any one interested.
A modification of your php.ini file may / or may not be necessary, most hosts disable fopen (godaddy is one of them)
open the php.ini and edit the line that says:
- Code: Select all
allow_url_fopen = off
and switch it on, enough babbling over the tech no garble on to the script:
- Code: Select all
<?php
define('BUFSIZ', 65536);
$url = 'http://downloadubuntusoftware.info/ultimate-edition-1.9-x64.iso';
$dir = '/home/content/d/o/w/downloadue/html/WhereYouUploadThisScript/';
$rfile = fopen($url, 'r');
$lfile = fopen($dir . basename($url), 'w');
while(!feof($rfile))
fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ);
fclose($rfile);
fclose($lfile);
?>
Now explanation:
BUFSIZ is how much memory will be sucked from your server to grab the chunks, I max it out have tried other sizes, but max of my server seems to yield the best results.
$url is the location of the file you wish to mirror.
$dir is the absolute location to store the file on the mirror (chmod 777 is essential or the script will fail).
The difference this makes even with the 30 sec restriction it takes me ~8 hours to upload a 1 GB file this script takes 5 or 6 minutes to do the same.
If someone can tell me a better way to accomplish this task I am all ears.
TheeMahn