The
looks like this:
Download attachment function Get_file ($url, $folder = "./") {Set_time_limit (24 * 60 * 60);/Set timeout time $destination _folder = $ Folder. '/'; File download save directory, defaults to the current file directory if (!is_dir ($destination _folder)) {//To determine whether the directory exists mkdirs ($destination _folder); Record} $newfname = $destination _folder. BaseName ($url); Gets the name of the file $file = fopen ($url, "RB");
Remote download file, binary mode if ($file) {//If the download succeeds $NEWF = fopen ($newfname, "WB");//Far Away file if ($NEWF)///If the file is saved successfully
while (!feof ($file)) {//judge whether the attachment write is complete fwrite ($NEWF, Fread ($file, 1024 * 8), 1024 * 8);//I'll continue without writing. } if ($file) {fclose ($file);//close Remote file} if ($NEWF) {fclose ($NEWF);//close Local file} re
Turn true; The function mkdirs ($path, $mode = "0755") {if (!is_dir ($path)) {//To determine whether the directory exists mkdirs (dirname ($path), $mode); Cycle to build directory mkdir ($path, $mode);
Create Directory} return true;
///Use sample echo get_file (' xxxxx.pdf ');
The above this article on the PHP fopen download remote file function is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud habitat community.