Remote File Download to space using PHP

Source: Internet
Author: User

I just moved to the blog and planned to migrate the data in two spaces. But when something went wrong, I thought that PHP could remotely download files when the packaged files were too large.
Then I wrote a script!

01 <?php
02 if ($_GET[xfer]) {
 
03 if ($_POST[from] == "") {
04 print "You forgot to enter a url.";
 
05 } else {
06 copy("$_POST[from]", "$_POST[to]");
 
07 $size = round((filesize($_POST[to])/1000000), 3);
08 print "transfer complete.<br>
 
09 <a><a href=\"$_POST[from]\">$_POST[from]</a><br>
10 <a><a href=\"$_POST[to]\">$_POST[to]</a> : $size MB";
 
11 }
12 } else {
 
13 print "<form action=\"$PHP_SELF?xfer=true\" method=post>
14 Remote File (please include http: //): <input name = from> <br>
 
15 Save file name: <input name = to> <br>
16 <input type=submit value=\"transload\">";
 
17 }
18 ?>
However, not all virtual hosts support this function. You have to check whether some functions are enabled. I don't know what functions are supported.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.