note 118684 added to function.header

From: Date: Tue, 19 Jan 2016 14:23:58 +0000
Subject: note 118684 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-204717@lists.php.net to get a copy of this message
According to the RFC 6226 (https://tools.ietf.org/html/rfc6266), the only way to send Content-Disposition Header with encoding is: Content-Disposition: attachment; filename*= UTF-8''%e2%82%ac%20rates for backward compatibility, what should be sent is: Content-Disposition: attachment; filename="EURO rates"; filename*=utf-8''%e2%82%ac%20rates As a result, we should use <?php $filename = '中文文件名.exe'; // a filename in Chinese characters $contentDispositionField = 'Content-Disposition: attachment; ' . sprintf('filename="%s"; ', rawurlencode($filename)) . sprintf("filename*=utf-8''%s", rawurlencode($filename)); header('Content-Type: application/octet-stream'); header($contentDispositionField); readfile('file_to_download.exe'); ?> I have tested the code in IE6-10, firefox and Chrome. ---- Server IP: 72.52.91.14 Probable Submitter: 113.97.60.78 ---- Manual Page -- http://php.net/manual/en/function.header.php Edit -- https://master.php.net/note/edit/118684 Del: integrated -- https://master.php.net/note/delete/118684/integrated Del: useless -- https://master.php.net/note/delete/118684/useless Del: bad code -- https://master.php.net/note/delete/118684/bad+code Del: spam -- https://master.php.net/note/delete/118684/spam Del: non-english -- https://master.php.net/note/delete/118684/non-english Del: in docs -- https://master.php.net/note/delete/118684/in+docs Del: other reasons-- https://master.php.net/note/delete/118684 Reject -- https://master.php.net/note/reject/118684 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204717) next »