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);
readfile
Moderator: General Moderators
Re: readfile
Just did a quick look...
You don't say that you get a new window or not.
I'm guessing you don't get a new wndow, and instead you get the little image as if it did not load.
Anyway, what caught my eye, was the target. target="blank" tells html to open a frame named blank, target="_blank" tells it to open a new window.
You don't say that you get a new window or not.
I'm guessing you don't get a new wndow, and instead you get the little image as if it did not load.
Anyway, what caught my eye, was the target. target="blank" tells html to open a frame named blank, target="_blank" tells it to open a new window.
Re: readfile
I do get a new window, just not the image although I get a little image box. If I change Content Disposition to attachment I get the correct image. Problem is I want to display it. I also just notice this only happens with tif files.
Re: readfile
Try adding:
Code: Select all
header('Content-type: image/tiff');