ThanderMaX wrote:
> On Jun 14, 3:19 am, tomhawki...@gmail.com 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
>
That depends on how the user has the browser (any browser) configured.
You can recommend something (which is what your content-disposition
does), but you can't force something on the user.
Also, your recommendation would do exactly the opposite of what he wants.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================