can php download exe files?

Source: Internet
Author: User
Tags fread php download readfile
PHP can download exe files like download rar First fread in the output of the download, do not access the EXE file in the site's path to download, can you achieve this effect?


Reply to discussion (solution)

With the same request
Not as far as I know.


Here you can add the code you want to add, such as:
/*
if (! ( $_server[' Http_referer ' && strpos ($_server[' http_referer '], ' http://'. $_server[' http_host ']) = = = 0)) {
Die (' prohibit off-station operation! ');
}
*/

Header (' Content-type:application/octet-stream '); EXE file in MIME format
Header (' content-disposition:attachment; Filename=yournewfilename.exe '); You want to download as a new file name
echo file_get_contents (' Yourfile.exe '); Fetch the file source, of course, here can also use fopen, fread read the file

?>

Gets the path of the file, compressed and then downloaded.

The key is that the header is set correctly, otherwise the file data may be displayed directly in the browser.

The principle is feasible, depends on the service side configuration situation.

Of course. You can also use the ReadFile () method to read the file

Of course. You can also use the ReadFile () method to read the file
I try to use frend read after setting hearder output is can download exe, but I source is 90m exe file, download down really only 180b files, ...

Gets the path of the file, compressed and then downloaded.
Every time I use PHP to read EXE file after setting the header information output download download down the old only 180b files, under the guidance of the Guide, why AH?

The key is that the header is set correctly, otherwise the file data may be displayed directly in the browser.
Set, as if PHP can not read EXE file AH

PHP Script settings
Set_time_limit (0);
Give it a try? Is the file too large and timed out?

  • Related Article

    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.