Often write collector release interface need to use the function of remote attachment, so write a php remote download file to the local function, generally enough, if the server support Curl function, the program will give priority to select curl, the need for small partners can refer to.
The code is very simple no more nonsense, directly to serve:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 The |
|
and a remote download file to the server.
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27-28 |
<form method= "POST" > <input name= "url" size= "/> <input" name= "Submit" type= "Submit"/> </form > < PHP//maximum execution time in seconds Set_time_limit (24 * 60 * 60); if (!isset ($_post[' submit ')) Die (); Folder to save downloaded the 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);}?> |
The above mentioned is the entire content of this article, I hope you can enjoy.