PHP uses code to download files. We generally call URLs to download files, but this method cannot be used when ie can identify files opened, such as downloading an image or html webpage, in this case, we need to program that we generally call URLs to download files. However, this method cannot be used when ie can identify files opened, such as downloading an image or html webpage, in this case, programming is required. the following php code can be used:
If (empty ($ _ GET [FileName]) | empty ($ _ GET [FileDir]) | empty ($ _ GET [FileId]) {
Echo script alert ("illegal connection! "); Location. replace (" index. php ") script; exit ();
}
$ File_name = $ _ GET [FileName];
$ File_dir = $ _ GET [FileDir];
$ FileId = $ _ GET [FileId];
$ File_dir = $ file_dir ."/";
If (! File_exists ($ file_dir. $ file_name) {// check whether the file exists
Echo "file not found ";
Exit;
} Else {
$ File = fopen ($ file_dir. $ file_name, "r"); // open the file
// Input file tag
Header ("Content-type: application/octet-stream ");
Header ("Accept-Ranges: bytes ");
Header ("Accept-Length:". filesize ($ file_dir. $ file_name ));
Header ("Content-Disposition: attachment; filename =". $ file_name );
// Output file content
Echo fread ($ file, filesize ($ file_dir. $ file_name ));
Fclose ($ file );
Exit ();
}
?>
...