Home  >  Article  >  php教程  >  利用PHP实现远程下载文件到空间

利用PHP实现远程下载文件到空间

WBOY
WBOYOriginal
2016-06-13 10:53:43772browse

刚才给博客搬家,打算把两个空间的数据进行迁移但是遇到点问题,打包的文件太大了 没办法 就想到了PHP可以远程下载文件
 然后就写了个脚本!

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><a href="%5C%22%24_POST%5Bfrom%5D%5C%22">$_POST[from]</a><br>
10 <a></a><a href="%5C%22%24_POST%5Bto%5D%5C%22">$_POST[to]</a> : $size MB";
 
11 }
12 } else {
 
13 print "<form action="%5C%22%24PHP_SELF?xfer=true%5C%22" method="post"></form>
14 远程文件下载地址(请带上http://): <input name="from"><br>
 
15 保存文件名: <input name="to"><br>
16 <input type="submit" value='\"transload\"'>";
 
17 }
18 ?>
不过并不是所有的所有的虚拟主机都支持,得看某些函数是否开启,什么函数 我也不知道
 
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn