使用php从其他站点将文件下载到Web服务器

vol*_*man 7 php curl wget download

是否有可能下载文件大于200 MB到我的网站直接托管,使我没有那个文件下载到我的电脑,然后上传使用我的FTP客户端.因为我不使用ssh我不能使用wget.我在考虑php或per或cgi可能是..(对所有想法开放......)

+==============+                                  +--------+
|  Big server  | -----------+                +--->|web host|
+==============+            |   +------+     |    +--------+
                            +-->| MyPC |-----+        |
                                +------+              |     +========+
                                                      +---->| client |
                                                            +========+
Run Code Online (Sandbox Code Playgroud)

要么

+============+
| Big Server | ---+
+============+    |                      +----------+
                  +--------------------->| Web Host |
                                         +----------+
                                            |
   +------+                                 |      +========+
   | MyPC |                                 +----->| client |
   +------+                                        +========+
Run Code Online (Sandbox Code Playgroud)

请帮忙....

小智 7

对于cURL

$url = "http://path.com/file.zip";
$fh = fopen(basename($url), "wb");
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fh);
curl_exec($ch);
curl_close($ch);
Run Code Online (Sandbox Code Playgroud)


The*_*can 5

在 php 中最简单的可能是:

<?php
copy('http://server.com/big.file','/local/path/big.file');
?>
Run Code Online (Sandbox Code Playgroud)

但是您应该能够执行 wget。特别是如果您的服务器上的外部 fopen 被停用,这很可能

使用 php 就像:

<?php 
chdir('/where/i/want/to/download/the/file/');
system('wget http://server.com/big.file');
?>
Run Code Online (Sandbox Code Playgroud)

或者

<?php
system('wget -O /where/i/want/to/save http://server.com/big.file');
?>
Run Code Online (Sandbox Code Playgroud)

卷曲是另一种方式。您可以执行shell命令或使用curl php。

还要确保您要下载到的文件夹(或文件)是可写的