Can php download the exe file?-php Tutorial

Source: Internet
Author: User
Tags php download
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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.