How to solve the problem of downloading attachments in PHPIE

Source: Internet
Author: User
Before downloading the attachment in IE, you need to clear the cache and encode the Chinese file name with urlencode. The following is a good example. if you need it, refer to the following:

1. clear the cache before downloading attachments in IE.

2. the Chinese file name must be URL encoded.

The code is as follows:


Header ("Pragma:"); // if it is not added, IE will prompt that the target host cannot be accessed.
Header ("Cache-Control:"); // if it is not added, IE will prompt that the target host cannot be accessed.
Header ("content-type: $ type ");
Header ("accept-ranges: bytes ");
Header ("Content-Transfer-Encoding: base64 ");
Header ("accept-length:". filesize ($ path_c ));
Header ("content-disposition: attachment; filename =". urlencode ($ filename); // garbled characters will appear in Chinese names without urlencode in IE
Readfile ($ path_c );
Exit;


Or

The code is as follows:


Header ('content-Description: File Transfer ');
Header ('content-Type: application/octet-stream ');
Header ('content-Disposition: attachment; filename = '. urlencode (basename ($ file); // garbled characters will appear in Chinese names without urlencode in IE
Header ('content-Transfer-Encoding: binary '); // binary Transfer
Header ('expires: 0 ');
Header ('cache-Control: must-revalidate, post-check = 0, pre-check = 0'); // if no value is added, IE will prompt that the target host cannot be accessed.
Header ('pragma: public '); // If this parameter is not added, IE will prompt that the target host cannot be accessed.
Header ('content-Length: '. filesize ($ file ));
Ob_clean ();
Flush ();
Readfile ($ file );
Exit;

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.