Php downloads and saves files to a local device. First, copy the code as follows :? Phpfunctiondownfile(%%%%filenamerealpath(resume.html); file name $ datedate (Ymd-H: I: m); Header (Content-type: applicationoctet-first type:
The code is as follows:
Function downfile ()
{
$ Filename = realpath ("resume.html"); // file name
$ Date = date ("Ymd-H: I: m ");
Header ("Content-type: application/octet-stream ");
Header ("Accept-Ranges: bytes ");
Header ("Accept-Length:". filesize ($ filename ));
Header ("Content-Disposition: attachment; filename = paipaidate}.doc ");
Echo file_get_contents ($ filename );
Readfile ($ filename );
}
Downfile ();
?>
Or
The code is as follows:
Function downfile ($ fileurl)
{
Ob_start ();
$ Filename = $ fileurl;
$ Date = date ("Ymd-H: I: m ");
Header ("Content-type: application/octet-stream ");
Header ("Accept-Ranges: bytes ");
Header ("Content-Disposition: attachment; filename = paipaidate}.doc ");
$ Size = readfile ($ filename );
Header ("Accept-Length:". $ size );
}
$ Url = "url address ";
Downfile ($ url );
?>
Second:
The code is as follows:
Function downfile ($ fileurl)
{
$ Filename = $ fileurl;
$ File = fopen ($ filename, "rb ");
Header ("Content-type: application/octet-stream ");
Header ("Accept-Ranges: bytes ");
Header ("Content-Disposition: attachment; filename = 4.doc ");
$ Contents = "";
While (! Feof ($ file )){
$ Contents. = fread ($ file, 8192 );
}
Echo $ contents;
Fclose ($ file );
}
$ Url = "url address ";
Downfile ($ url );
?>
The pipeline code is as follows :? Php function downfile () {$ filename = realpath ("resume.html"); // file name $ date = date ("Ymd-H: I: m "); header ("Content-type: application/octet -...