Talking about the function of php fopen to download remote files,
As follows:
// Download the attachment function get_file ($ url, $ folder = ". /") {set_time_limit (24*60*60); // set the timeout value $ destination_folder = $ folder. '/'; // File Download and save directory. The default value is the current file directory if (! Is_dir ($ destination_folder) {// determine whether the directory contains mkdirs ($ destination_folder); // if not, create a directory} $ newfname = $ destination_folder. basename ($ url); // get the file name $ file = fopen ($ url, "rb"); // Remote file Download, binary mode if ($ file) {// if the download is successful $ newf = fopen ($ newfname, "wb"); // if ($ newf) in the distant 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 ); // continue without writing.} if ($ file) {fclose ($ file); // close Remote file} if ($ newf) {fclose ($ newf ); // close local file} return true;} function mkdirs ($ path, $ mode = "0755") {if (! Is_dir ($ path) {// determine whether the directory contains mkdirs (dirname ($ path), $ mode); // create the directory mkdir cyclically ($ path, $ mode ); // create a directory} return true;} // use the example echo get_file('xxxxx ');
The above discussion about php fopen's function for downloading remote files is all the content that I have shared with you. I hope to give you a reference and support for the help house.