Re: IE 'hangs' when I try to display an uploaded file
- From: ThanderMaX <aniruddha.aot@xxxxxxxxx>
- Date: Sat, 14 Jun 2008 11:23:57 -0700 (PDT)
On Jun 14, 3:19 am, tomhawki...@xxxxxxxxx wrote:
Hi
I currently have a site where users can upload files. These files can
be doc, wmv, jpeg, xls, dwf, dwf and dwg.
These files are uploaded to /home/**user**/uploads and not /home/
**user**/public_html/uploads to prevent any old user from browsing
them.
I then use a general showDoc page with the following function (from
php.net)
function readfile_chunked($filename,$retbytes=true) {
$chunksize = 1*(1024*1024); // how many bytes per chunk
$buffer = '';
$cnt =0;
// $handle = fopen($filename, 'rb');
$handle = fopen($filename, 'rb');
if ($handle === false) {
return false;
}
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
echo $buffer;
ob_flush();
flush();
if ($retbytes) {
$cnt += strlen($buffer);
}
}
$status = fclose($handle);
if ($retbytes && $status) {
return $cnt; // return num.. bytes delivered like readfile() does.
}
return $status;
}
which is called here
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: $ctype");
header("Content-Disposition: inline; filename=
\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
readfile_chunked("$filename");
exit();
Now, if I have a file of more than about 3MB (tried with a wmv and
dxf), it won't show, and my whole site becomes unresponsive to any
input until I close the browser, open IE again and log in again.
filename and ctype must be being passed correctly but the size of the
file seems to make it hang. I have succeded in uploading files of up
to 15MB but the larger ones won't display!
Any ideas?
TomH
Try "Content-Disposition: attachment;......"
It will show the open/save dialog box in IE
.
- Follow-Ups:
- Re: IE 'hangs' when I try to display an uploaded file
- From: Jerry Stuckle
- Re: IE 'hangs' when I try to display an uploaded file
- References:
- IE 'hangs' when I try to display an uploaded file
- From: tomhawkins1
- IE 'hangs' when I try to display an uploaded file
- Prev by Date: Re: very basic: session_start();
- Next by Date: Re: finding compile time errors
- Previous by thread: Re: IE 'hangs' when I try to display an uploaded file
- Next by thread: Re: IE 'hangs' when I try to display an uploaded file
- Index(es):
Relevant Pages
|