Menu

#3 max file size logic in ClassConference

open
nobody
None
5
2005-03-22
2005-03-22
Anonymous
No

There are really two issues here.

First, ClassConference.inc includes logic in the
storePaper() function (around line 594) that goes
something like this:

$size = $uploadedFileName;
$maxsize = get_cfg_var("upload_max_filesize");
if ($size > $maxsize) {
$this->errorMsg("Your file is $mysize bytes,
which is larger than the maximum "
. "upload size of $maxsize --
double check your file. "
. "If you need this limit
increased, contact $this->contactEmail");
}

The comparison of $size with $maxsize is not correct,
as size is initialized to the string variable
uploadedFileName (provided as an argument to the
storePaper() routine.

If the actual file size is to be compared, then the
above assignment statement should be replaced with:

$size = filesize($uploadedFileName);

However, since papers are base64 encoded, they are
going to grow in size. Therefore, a paper that is say,
800KB, will actually get expanded to over 1 MB, which
may violate the restrictions set up by the conference
admin.

There is a subtle issue that manifests here (even
though you warn about it in the install document). When
the paper is actually saved to the database (around
line 684 of ClassConference.inc), the MySQL concat()
function is used. However, large papers (base64-encoded
larger than 1MB) fail to upload -- there is not even
half or a chunk of the paper in the database. Instead
the filed PaperStorage.paper is NULL -- not what you'd
expect if the transaction is failing halfway (or most
of the way) through.

You warn about this, but the MySQL database variable
"max_allowed_packet" needs to be set larger than 1MB
(which is the default when doing a standard MySQL
installation on Linux). You should tell users how to
fix this in the same place that you warn about it.

Log into the database as the 'database root' user and
issue the following command:

SET max_allowed_packet = 10000000;

to be able to upload papers up to 10MB (unrealistic in
some cases, but even 4 MB is a reasonable limit). The
biggest problem was that it was failing without any
error messages. It would be nice if the storePaper()
routine retrieved the value of this variable, tested
the base64-encoded file size against it, and displayed
a warning message to the user.

Cheers,
Michael
mlocasto AT acm.org

Discussion


Log in to post a comment.

MongoDB Logo MongoDB