$file_text = '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($file_text)); Header('Content-disposition: attachment; filename="downloaded_file.txt"'); echo $file_text; exit();