PHP: Force the browser to download the text in file
- $text_in_file = 'Put some text here';
- if (isset($_SERVER['HTTP_USER_AGENT']) and strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
- Header('Content-Type: application/force-download');
- else
- Header('Content-Type: application/octet-stream');
- Header('Accept-Ranges: bytes');
- Header('Content-Length: ' . strlen($text_in_file)); // text to file
- Header('Content-disposition: attachment; filename="downloaded_filename.txt"');
- echo $text_in_file;
- exit();
Комментариев нет:
Отправить комментарий