Reputation: 317
is it possible to download file larger than 200 mb onto my web hosting directly so that i dont have to download that file to my computer and then upload using my ftp client. and as i am not using ssh i cannot use wget. i was thinking of php or per or cgi may be.. (open to all ideas..)
+==============+ +--------+
| Big server | -----------+ +--->|web host|
+==============+ | +------+ | +--------+
+-->| MyPC |-----+ |
+------+ | +========+
+---->| client |
+========+
or
+============+
| Big Server | ---+
+============+ | +----------+
+--------------------->| Web Host |
+----------+
|
+------+ | +========+
| MyPC | +----->| client |
+------+ +========+
plz help....
Upvotes: 7
Views: 9231
Reputation: 191
For 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);
Upvotes: 8
Reputation: 29866
in php the easiest is probably:
<?php
copy('http://server.com/big.file','/local/path/big.file');
?>
however you should be able to execute wget. especially if external fopen is deactivated on your server which is very likely
using php just like:
<?php
chdir('/where/i/want/to/download/the/file/');
system('wget http://server.com/big.file');
?>
or
<?php
system('wget -O /where/i/want/to/save http://server.com/big.file');
?>
curl is another way. you can execute the shell command or use curl php.
also make sure the folder (or file) you want to download to is writeable
Upvotes: 5
Reputation: 91932
With PHP you can download the file with this:
<?php
$in = fopen('http://example.com/', 'r');
$out = fopen('local-file', 'w');
while(!feof($in)) {
$piece = fread($in, 2048);
fwrite($out, $piece);
}
fclose($in);
fclose($out);
?>
This requires two things:
Upvotes: 2