Ec (2); php automatically downloads remote server files & lt; formmethod & quot; post & quot; & gt; & lt; inputname & quot; url & quot; size & quot; 50 & quot; & gt; & lt; inputname & quot; submit & quot; type & quot; submit & quot; & gt; & lt; form & gt; & script ec (2); script
Php automatically downloads remote server files
<? Php
// Maximum execution time in seconds
Set_time_limit (24*60*60 );
If (! Isset ($ _ POST ['submit ']) die ();
// Folder to save downloaded files to. must end with slash
$ Destination_folder = 'temp /';
$ Url = $ _ POST ['url'];
$ Newfname = $ destination_folder. basename ($ url );
$ File = fopen ($ url, "rb ");
If ($ file ){
$ Newf = fopen ($ newfname, "wb ");
If ($ newf)
While (! Feof ($ file )){
Fwrite ($ newf, fread ($ file, 1024*8), 1024*8 );
}
}
If ($ file ){
Fclose ($ file );
}
If ($ newf ){
Fclose ($ newf );
}
?>