Download file program using php on unix box
I have created a beginner program to forcefully download file from unix
box to windows through browser, it is not throwing any error but shows
nothing on browser just a blank page.
PHP version- 5.2.13 Apache-2.0 Unix Box- HP-UX 11.11 (old version latest
is 11.31) local PC- windows XP Prof. Browser- IE 7, Mozilla .
Below is my code(this code resides on unix box):
<?php
ob_start();
$file = '/opt/hpws/apache/htdocs/barn/file2';
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream;charset=utf-8');
header('Content-Disposition: attachment; filename=$file');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
}
?>
No comments:
Post a Comment