473,479 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

IE 'hangs' when I try to display an uploaded file

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
Jun 27 '08 #1
9 2050
On Jun 14, 11: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

A quick update. If I right click the link and save target as, the
files download perfectly but I want to display, not download them. Two
things happen though. No other link on the site will work until the
file has finished downloading. Secondly, it I cancel the download
before it completes, the same 'hang' happens and I have to close and
reopen the browser.

TomH.
Jun 27 '08 #2
to*********@gmail.com wrote:
On Jun 14, 11: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


A quick update. If I right click the link and save target as, the
files download perfectly but I want to display, not download them. Two
things happen though. No other link on the site will work until the
file has finished downloading. Secondly, it I cancel the download
before it completes, the same 'hang' happens and I have to close and
reopen the browser.

TomH.
Try a different browser.

The "no other link on the site will work" can be normal, depending on
how your code is structured. The rest of your problems sound like a
browser problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #3
On Jun 14, 1:09*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
tomhawki...@gmail.com wrote:
On Jun 14, 11: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
A quick update. If I right click the link and save target as, the
files download perfectly but I want to display, not download them. Two
things happen though. No other link on the site will work until the
file has finished downloading. Secondly, it I cancel the download
before it completes, the same 'hang' happens and I have to close and
reopen the browser.
TomH.

Try a different browser.

The "no other link on the site will work" can be normal, depending on
how your code is structured. *The rest of your problems sound like a
browser problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -
I'll try something else. When you say 'depends on how your code is
structured', short of a mysql query to get the filename, the code is
above. Is there anything in that?

TomH.
Jun 27 '08 #4
to*********@gmail.com wrote:
On Jun 14, 1:09 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>tomhawki...@gmail.com wrote:
>>On Jun 14, 11: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
A quick update. If I right click the link and save target as, the
files download perfectly but I want to display, not download them. Two
things happen though. No other link on the site will work until the
file has finished downloading. Secondly, it I cancel the download
before it completes, the same 'hang' happens and I have to close and
reopen the browser.
TomH.
Try a different browser.

The "no other link on the site will work" can be normal, depending on
how your code is structured. The rest of your problems sound like a
browser problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

I'll try something else. When you say 'depends on how your code is
structured', short of a mysql query to get the filename, the code is
above. Is there anything in that?

TomH.
I'm sure that isn't your entire page. There's a lot more to it. For
instance, sessions are single threaded by PHP. You probably start a
session before the download, and don't close it until the page ends.
During this time, you will not be able to access other pages which use
sessions (but other people can access their pages because they're using
different sessions).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #5
On Jun 14, 1:26*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
tomhawki...@gmail.com wrote:
On Jun 14, 1:09 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
tomhawki...@gmail.com wrote:
On Jun 14, 11: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
A quick update. If I right click the link and save target as, the
files download perfectly but I want to display, not download them. Two
things happen though. No other link on the site will work until the
file has finished downloading. Secondly, it I cancel the download
before it completes, the same 'hang' happens and I have to close and
reopen the browser.
TomH.
Try a different browser.
The "no other link on the site will work" can be normal, depending on
how your code is structured. *The rest of your problems sound like a
browser problem.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
- Show quoted text -
I'll try something else. When you say 'depends on how your code is
structured', short of a mysql query to get the filename, the code is
above. Is there anything in that?
TomH.

I'm sure that isn't your entire page. *There's a lot more to it. *For
instance, sessions are single threaded by PHP. *You probably start a
session before the download, and don't close it until the page ends.
During this time, you will not be able to access other pages which use
sessions (but other people can access their pages because they're using
different sessions).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -
I see. That's true.

Here's the structure then.
Show Doc.
Include functions file (which has session_start()) at the top in
addition to connections to mysql.
Perform mysql query using GET vars and SESSION vars.
Determine the filename I want to display.
readfile_chunked the file.

From what you say, unless the page ends, the session will be
'locked'. If I pass the session variables via GET instead and close
the session as the 2nd line of showdoc.php (1st line includes the file
which starts the session) before I get the filename data and display
it, will that work?
TomH.
Jun 27 '08 #6
to*********@gmail.com wrote:
On Jun 14, 1:26 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>tomhawki...@gmail.com wrote:
>>On Jun 14, 1:09 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
tomhawki...@gmail.com wrote:
On Jun 14, 11: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
A quick update. If I right click the link and save target as, the
files download perfectly but I want to display, not download them. Two
things happen though. No other link on the site will work until the
file has finished downloading. Secondly, it I cancel the download
before it completes, the same 'hang' happens and I have to close and
reopen the browser.
TomH.
Try a different browser.
The "no other link on the site will work" can be normal, depending on
how your code is structured. The rest of your problems sound like a
browser problem.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
- Show quoted text -
I'll try something else. When you say 'depends on how your code is
structured', short of a mysql query to get the filename, the code is
above. Is there anything in that?
TomH.
I'm sure that isn't your entire page. There's a lot more to it. For
instance, sessions are single threaded by PHP. You probably start a
session before the download, and don't close it until the page ends.
During this time, you will not be able to access other pages which use
sessions (but other people can access their pages because they're using
different sessions).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

I see. That's true.

Here's the structure then.
Show Doc.
Include functions file (which has session_start()) at the top in
addition to connections to mysql.
Perform mysql query using GET vars and SESSION vars.
Determine the filename I want to display.
readfile_chunked the file.

From what you say, unless the page ends, the session will be
'locked'. If I pass the session variables via GET instead and close
the session as the 2nd line of showdoc.php (1st line includes the file
which starts the session) before I get the filename data and display
it, will that work?
TomH.
The problem is the session itself is locked as long as it is open. It
doesn't make any difference if you pass variables in the $_GET or not.
Just close the session as soon as you're done with it (i.e. before you
start the file download).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #7
On Jun 14, 2:51*pm, tomhawki...@gmail.com wrote:
On Jun 14, 1:26*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:


tomhawki...@gmail.com wrote:
On Jun 14, 1:09 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>tomhawki...@gmail.com wrote:
>>On Jun 14, 11: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
>>A quick update. If I right click the link and save target as, the
>>files download perfectly but I want to display, not download them. Two
>>things happen though. No other link on the site will work until the
>>file has finished downloading. Secondly, it I cancel the download
>>before it completes, the same 'hang' happens and I have to close and
>>reopen the browser.
>>TomH.
>Try a different browser.
>The "no other link on the site will work" can be normal, depending on
>how your code is structured. *The rest of your problems sound like a
>browser problem.
>--
>==================
>Remove the "x" from my email address
>Jerry Stuckle
>JDS Computer Training Corp.
>jstuck...@attglobal.net
>==================- Hide quoted text -
>- Show quoted text -
I'll try something else. When you say 'depends on how your code is
structured', short of a mysql query to get the filename, the code is
above. Is there anything in that?
TomH.
I'm sure that isn't your entire page. *There's a lot more to it. *For
instance, sessions are single threaded by PHP. *You probably start a
session before the download, and don't close it until the page ends.
During this time, you will not be able to access other pages which use
sessions (but other people can access their pages because they're using
different sessions).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text-
- Show quoted text -

I see. That's true.

Here's the structure then.
Show Doc.
Include functions file (which has session_start()) at the top in
addition to connections to mysql.
Perform mysql query using GET vars and SESSION vars.
Determine the filename I want to display.
readfile_chunked the file.

From what you say, *unless the page ends, the session will be
'locked'. If I pass the session variables via GET instead and close
the session as the 2nd line of showdoc.php (1st line includes the file
which starts the session) before I get the filename data and display
it, will that work?
TomH.- Hide quoted text -

- Show quoted text -
Scratch that. Just don't start the session in the first place.

Works fine now. I just pass the var I was storing in session via GET
and go from there.

Thanks for you help - I never would have thought it was related to
sessions.
TomH
Jun 27 '08 #8
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
Jun 27 '08 #9
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.
js*******@attglobal.net
==================

Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5493
by: Andrew Crowe | last post by:
Hi guys, I'm using ImageMagick to do scaling / filtering to uploaded images by calling the following: exec("cmd.exe /c convert.exe -filters in.jpg out.jpg"); This works flawlessly on our...
1
6366
by: Lize | last post by:
Hi, I'm writing an ASP application to open an excel workbook, then run a macro stored in the excel file, which produces outputs that will be displayed back onto my ASP application. Now the...
8
2775
by: Al Knowles | last post by:
I have researched and tried every method I can find for passing a two-page tif file from a VB6 application to a web service via XML. These include XMLTextReader.ReadBase64, Convert.FromBase64,...
1
1667
by: Scott | last post by:
I am trying to write an asp.net web page that will spawn a third party .exe file and return the results back to my asp page. I am able to write a vb.net program that will do this just fine. I...
0
1600
by: Jeff | last post by:
Hi - I have an ASP.NET page that hangs (some times; if it loads for you, try refresh/F5 several times) when I try to run it on my localhost. It contains an HTML table for formatting, and within...
3
1505
by: Lars Netzel | last post by:
Hi! A button triggers the code.. I'm trying to learn about the XmlSerializer and when the code comes the try statement it doesn' throw an exception, it goes into the...
11
1983
by: agarwalsrushti | last post by:
Hi, Ive created a registration page in which at the last it asks the user to upload the resume file. When the user clicks on the upload button to upload the file it automativcally submits all the...
1
1959
by: =?Utf-8?B?TmFt?= | last post by:
ASP.NET 1.1.4322 Server1: Windows Server Enterprise Ed 2003 – SP2 Server2: Same as Server 1. IE 6.0 –SP2 After we migrated our website from server1 to server2 everything works fine accept...
2
5511
by: Patrick Finnegan | last post by:
Running db2 8.2 ON aIX 5.3. We have a third party USEREXIT program that periodically hangs for some unknown reason. Db2 generates error message to the diag log. MESSAGE : Successfully...
0
6899
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6719
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6847
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5312
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4757
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4463
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2980
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2970
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.