readfile
Posted: Tue Jul 20, 2010 3:22 pm
I am doing a simple look up and display file. I want to use POST for more security. to display the file I use readfile and the Content-Disposition: inline heading parameter. when I make this call in the same window no problem but when I open a new window I just get a little image as if it did not load. any suggestions? Here is some code:
This one Works
<form name='myform' action='readfile2.php' method='post'>
<input type=hidden name='doc_id' value=''>
<input type=hidden name='fileID' value=''>
<input type=hidden name='tab' value=''>
<input type=hidden name='cab' value=''>
<input type=hidden name='ID' value=''>
<input type=hidden name='download' value='0'>
<input type=hidden name='filename' value=''>
<input type=hidden name='delete' value='0'>
<input type=hidden name='tmp' value=''>
</form>
... read sql get full path
$headerArr = array (
'Content-type: '.$type,
'Content-Length: '.$fsize,
'Cache-Control:',
'Pragma:',
'Content-Disposition: inline; filename="'.$headerFName.'"',
);
ini_set('zlib.output_compression', 'Off');
foreach($headerArr as $myHeader) {
header($myHeader);
}
readfile($finalPath);
****************************
and this one doesnt work:
<form name='myform' action='readfile2.php' method='post' target='blank'>
<input type=hidden name='doc_id' value=''>
<input type=hidden name='fileID' value=''>
<input type=hidden name='tab' value=''>
<input type=hidden name='cab' value=''>
<input type=hidden name='ID' value=''>
<input type=hidden name='download' value='0'>
<input type=hidden name='filename' value=''>
<input type=hidden name='delete' value='0'>
<input type=hidden name='tmp' value=''>
</form>
... read sql get full path
$headerArr = array (
'Content-type: '.$type,
'Content-Length: '.$fsize,
'Cache-Control:',
'Pragma:',
'Content-Disposition: inline; filename="'.$headerFName.'"',
);
ini_set('zlib.output_compression', 'Off');
foreach($headerArr as $myHeader) {
header($myHeader);
}
readfile($finalPath);
This one Works
<form name='myform' action='readfile2.php' method='post'>
<input type=hidden name='doc_id' value=''>
<input type=hidden name='fileID' value=''>
<input type=hidden name='tab' value=''>
<input type=hidden name='cab' value=''>
<input type=hidden name='ID' value=''>
<input type=hidden name='download' value='0'>
<input type=hidden name='filename' value=''>
<input type=hidden name='delete' value='0'>
<input type=hidden name='tmp' value=''>
</form>
... read sql get full path
$headerArr = array (
'Content-type: '.$type,
'Content-Length: '.$fsize,
'Cache-Control:',
'Pragma:',
'Content-Disposition: inline; filename="'.$headerFName.'"',
);
ini_set('zlib.output_compression', 'Off');
foreach($headerArr as $myHeader) {
header($myHeader);
}
readfile($finalPath);
****************************
and this one doesnt work:
<form name='myform' action='readfile2.php' method='post' target='blank'>
<input type=hidden name='doc_id' value=''>
<input type=hidden name='fileID' value=''>
<input type=hidden name='tab' value=''>
<input type=hidden name='cab' value=''>
<input type=hidden name='ID' value=''>
<input type=hidden name='download' value='0'>
<input type=hidden name='filename' value=''>
<input type=hidden name='delete' value='0'>
<input type=hidden name='tmp' value=''>
</form>
... read sql get full path
$headerArr = array (
'Content-type: '.$type,
'Content-Length: '.$fsize,
'Cache-Control:',
'Pragma:',
'Content-Disposition: inline; filename="'.$headerFName.'"',
);
ini_set('zlib.output_compression', 'Off');
foreach($headerArr as $myHeader) {
header($myHeader);
}
readfile($finalPath);