I’ve used this little script quite a bit while moving servers, and it’s saved me tons of time. It allows you to transfer large files from one server to another by breaking up the file into 1MB pieces to avoid memory limits. There seems to be a 2GB maximum on transfer sizes.
To use it, simply change the variable $path to a relative path on your new server where you want the file to be saved to, change the variable $url to the web-accessible location of the file on the old server, and upload and run the script on your new server.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <?php set_time_limit(0); //Unlimited max execution time $path = 'newfile.zip'; $url = 'http://example.com/oldfile.zip'; $newfname = $path; echo 'Starting Download!<br>'; $file = fopen ($url, "rb"); if($file) { $newf = fopen ($newfname, "wb"); if($newf) while(!feof($file)) { fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 ); echo '1 MB File Chunk Written!<br>'; } } if($file) { fclose($file); } if($newf) { fclose($newf); } echo 'Finished!'; ?> |
nice and thanks.
Informative article, just what I was looking for.
Very nice,Simple and Lite script..
It saved my lot of time . It transferred ~700 MB data with in Less than one minute
nice script, thanks
its nice but i need to run script from source
can you send that script
Simply save the code in a PHP file and run that on your server.
Thanks alot, very good script. another script:
I am using this for 3.5 gb file but this not work for me. what can i do for transferring 3.5 gig website to another hosting. the first hosting hasn’t cpanel.
Unfortunately, due to the 2GB maximum, you’ll have to manually move those files over or split them up into multiple files under 2GB in size.
I try to move 100mb files to another server and its worked in a few seconds..
Great script!
How exactly are the 1024 and 8 determined? For a file under 1MB, it will write about 20 lines of “1 MB File Chunk Written!”
You can reduce the chunk to less than one MB if file size of of < 1mb 😉 It may effect on transferring time etc?? :O
Thanx Paulin ..
i’m using your scripts .. amazing script
wow … nice it’s working … thank you ! :3
If the file is less than 1MB then we can reduce the size of chunks. Will it effect to the transferring speed (time)? and on server’s busyness 😉
I think you can reply because you have written this short and nice script 🙂
You should be able to reduce the size without having a noticeable effect.
Thank you for your script……..
We can say that it is a time saving mechanisms…..my 50MB file transferred just in 15 seconds …
Keep it up dude…..
Thanks again……
Thank you,
Simple and very useful script, it saved a lot of time
Awesome work Justin!
if the newfile uses no path, like the sample, so it means the downloaded file will be placed at the same location as the php file right? because unlike the other, i can’t make this script run on my server 🙁
Thank you for this. Have used it many times in the past. Has saved me a lot of work and given me lots of spare time to idle while working. Much appreciated.
I have no idea how to say Thank You! You did awesome brother 😀
Nice & Flexible to use your File Transferring Script.
Thanks you. the script is working.
I want to cry :D, thanks a lot. It saves me a lot of time. Thank you so much bro!
Great man…. Really Useful…
ohhhh my god! Bro you save my life… many many thanks to you. Your script worth $$100 million $$. you saved my lot of time…really salute to you! 🙂
Awesome!! it saved my 5 hours. Thank you for this script
Thanks a lot brother, You have done a tremendous job.
Hello,
I have used above script to transfer 800 MB of files but after 500MB of transfer we are getting error “Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.”
Do you have any idea to transfer big files through above script
Thanks in Advance.
Gulshan
thnks
thanks, work it.
Wow!!! Love it.. It save my internet data and time too…. thanks buddy for sharing this useful script.
that is great sir its for very easy and powerful… again thanks
i need two more scripts any body help me
1. how can i transfer more than 2 GB, very big file like 14GB size
2. how to transfer torrent data in my hosting site server? i mean same as this php scrip can i put any torent in my c panel server?
great aritcles, thanks for share it
Very useful snippet but contains some inaccuracies:
1024 * 8 = 8192 = 8 kB
Whereas for 1 MB you should have used:
1024 * 1024 = 1048576 = 1 MB
Nice script, thank you
i upload my folder in remote server in zip form now i am trying to upload my php script file which will extract my zip folder on that location.
but when i upload my php file. this executed itself and error occur.
please help me to fix this error
how to upload my project and unzip that folder with php code
Nice article. many many thanks for information
Hi many thanks for your script it works really well. Is it posssible to add a progress bar? Many thanks
i used it to move 7 GB data
life saving script
thanks
thank you so much
Nice Script,
Its not working for me its Stop at 300Mb.
Can Pls help me
verry good, tanks for share
I have a 38GB file that I need upload to aremote server. Can this script manage copy the whole file?
It save my internet data and time too…. thanks
Thanks a lot for the script 🙂