spikeyjames
asked on
wget and php
Hi,
I would like to use PHP to transfer files from remote servers onto my server. I have been informed that wget is the best method to use, the only problem is, I don't know how to use it! :)
So if anyone could create a small script in php which will allow me to use wget, and save the files to a selected directory, I would be extremely grateful!
I would like to use PHP to transfer files from remote servers onto my server. I have been informed that wget is the best method to use, the only problem is, I don't know how to use it! :)
So if anyone could create a small script in php which will allow me to use wget, and save the files to a selected directory, I would be extremely grateful!
ASKER
thanks a lot.
If I use <?php copy ();?>, does it give a limit to the file size I transfer? The files that I need to move to the server are several hundred MB each. If that is not a problem, then great!
If I use <?php copy ();?>, does it give a limit to the file size I transfer? The files that I need to move to the server are several hundred MB each. If that is not a problem, then great!
Hmm.. that indeed might be a problem, you could/would use set_time_limit() to prevent the script from timing out, but quit a loss when you set it to low and the script cancels when you've copied about 75% of the 700mb.
I don't know wether or not the programs called with exec() continue their work when the script timeouts. You should read the manual (php.net/exec) to discover.
I have an appointment at the moment, so can't do it for you.
good luck
-r-
I don't know wether or not the programs called with exec() continue their work when the script timeouts. You should read the manual (php.net/exec) to discover.
I have an appointment at the moment, so can't do it for you.
good luck
-r-
ASKER
i remember reading somewhere that it's the same with wget. So I think that copy() would do the job just as well.
Now my next problem is the code. How do I set the timeout limit? The server's connection is 10mb, and I would assume that the largest files I will be transfering will be around 750~800MB. So that's about 800 seconds, so say 1000 seconds to be safe.
I realise you're busy so don't worry, there's no rush. But if you could help me expand this code, I would appreciate it:
<?php
$remotefile = $_POST['remotefile'];
$localfile = "/files";
copy('$remotefile', '$localfile', ?TIMELIMIT?);
if (?COPY IS SUCCESSFUL?) {echo "Done";} else {echo "Error";}
?>
Now my next problem is the code. How do I set the timeout limit? The server's connection is 10mb, and I would assume that the largest files I will be transfering will be around 750~800MB. So that's about 800 seconds, so say 1000 seconds to be safe.
I realise you're busy so don't worry, there's no rush. But if you could help me expand this code, I would appreciate it:
<?php
$remotefile = $_POST['remotefile'];
$localfile = "/files";
copy('$remotefile', '$localfile', ?TIMELIMIT?);
if (?COPY IS SUCCESSFUL?) {echo "Done";} else {echo "Error";}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THANK YOU! You have been really helpful!
<?php copy('Remotefile', 'Localfile'); ?>
But when you are realy needing to use wget you would probably have to use the exec function:
http://nl2.php.net/manual/en/function.exec.php
<?php exec('wget params');
regards
-r-