| Home | Site Map | | ||
| CUBISTCODE | ||
|
PHP Download String
PHP function to force a browser to download the contents of a string variable as a file to the user's computer
function download_string($data,$filename,$mime_type='text/plain')
{
header('Content-Description: File Transfer');
header("Content-Type: $mime_type");
header("Content-Disposition: attachment; filename=$filename");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . strlen($data));
ob_clean();
flush();
echo $data;
}
Tags: developer, file, functions, php, scripts, web
|
| Home | Site Map | |