470,815 Members | 1,260 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

upload big file

Hi there,
I am using a POST method to upload a big file (20M), I have already
set the max-upload-file = 30M in php.ini and have the hidden
MAX_FILE_SIZE=30M in multipart form. However, it still refuse to upload
such file. For some reason, I am not going to use ftp instead. Any
idea?

Thanks in advance.

Jan 4 '06 #1
4 3991

wa***@wakun.com wrote:
Hi there,
I am using a POST method to upload a big file (20M), I have already
set the max-upload-file = 30M in php.ini and have the hidden
MAX_FILE_SIZE=30M in multipart form. However, it still refuse to upload
such file. For some reason, I am not going to use ftp instead. Any
idea?

Thanks in advance.


Now, I figure out the problem by setting the post_max_size=40M in
php.ini but I get another problem about offering a big file to
download. I have the download script as follow

$len = filesize($absfile);
$fd = fopen($absfile, "rb");
$contents = fread($fd, $len);
fclose($fd);

$t = "application/pdf";
header("Content-Type: $t");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=$filename");
header("Pragma: private"); // fix for IE

echo $contents;

I found it takes almost one minute to download the file bigger than
20M?

Jan 4 '06 #2

wa***@wakun.com wrote:
wa***@wakun.com wrote:
Hi there,
I am using a POST method to upload a big file (20M), I have already
set the max-upload-file = 30M in php.ini and have the hidden
MAX_FILE_SIZE=30M in multipart form. However, it still refuse to upload
such file. For some reason, I am not going to use ftp instead. Any
idea?

Thanks in advance.


Now, I figure out the problem by setting the post_max_size=40M in
php.ini but I get another problem about offering a big file to
download. I have the download script as follow

$len = filesize($absfile);
$fd = fopen($absfile, "rb");
$contents = fread($fd, $len);
fclose($fd);

$t = "application/pdf";
header("Content-Type: $t");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=$filename");
header("Pragma: private"); // fix for IE

echo $contents;

I found it takes almost one minute to download the file bigger than
20M?


You might want to try sending the file in "chunks". Remember that
$contents now contains at least 20MB of data in memory (and perhaps
elsewhere). See if something like this works better:

$fd = fopen($absfile, "rb");
while (!feof($fd))
echo fread($fd, 8192);

Jan 4 '06 #3
wa***@wakun.com wrote:
Now, I figure out the problem by setting the post_max_size=40M in
php.ini but I get another problem about offering a big file to
download. I have the download script as follow

$len = filesize($absfile);
$fd = fopen($absfile, "rb");
$contents = fread($fd, $len);
fclose($fd);

$t = "application/pdf";
header("Content-Type: $t");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=$filename");
header("Pragma: private"); // fix for IE

echo $contents;

I found it takes almost one minute to download the file bigger than
20M?


It's not a good idea to serve large PDF files through PHP. The Acrobat
Reader uses partial retrieval to allow a user to quickly jump to
different parts of a document. Unless you implement partial retrieval
yourself, or use the PEAR HTTP class, this functionality is disabled
and the user would have to wait for the whole document to finish
downloading.

Jan 4 '06 #4
On Wed, 04 Jan 2006 13:00:56 -0800, Chung Leong wrote:
the user would have to wait for the whole document to finish
downloading.


The user is always right and has to be punished for that.

--
http://www.mgogala.com

Jan 4 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by dave | last post: by
reply views Thread by SEMIH DEMIR | last post: by
9 posts views Thread by Wayne Smith | last post: by
7 posts views Thread by pbd22 | last post: by
5 posts views Thread by camphor | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.