Can php download exe files? can php download exe files? like rar, fread downloads files in the output first. do not access the exe file and download files in the website path, can this effect be achieved?
Reply to discussion (solution)
Same request, reserved name
I do not know.
// The code you want to add can be added here, for example:
/*
If (! ($ _ SERVER ['http _ referer'] & strpos ($ _ SERVER ['http _ referer'], 'http ://'. $ _ SERVER ['http _ host']) === 0 )){
Die ('prohibit operations outside the site! ');
}
*/
Header ('content-type: application/octet-stream'); // mime format of the exe file
Header ('content-Disposition: attachment; filename=yournewfilename.exe '); // you want to download the new file name
Echo file_get_contents('yourfile.exe '); // Obtain the file Source. of course, you can use fopen or fread to read the file.
?>
Obtain the file path, compress the file, and download it.
The key is that the header is correctly set; otherwise, the file data may be displayed directly in the browser.
In principle, it depends on the configuration of the server.
Of course. You can also use readfile () to read files.
Of course. You can also use readfile () to read files.
I tried to use frend to read the exe file that can be downloaded after setting the hearder, but my source is the 90m exe file. the downloaded file is indeed only 180b ,.......
Obtain the file path, compress the file, and download it.
Every time I use php to read the exe file, after setting the header information, I output the downloaded file that is only 180b. why?
The key is that the header is correctly set; otherwise, the file data may be displayed directly in the browser.
It seems that php cannot read the exe file.
Php script settings
Set_time_limit (0 );
Try? Is the file too large and times out?