Project

General

Profile

[Solved] Unable to upload file larger than 2gb

Added by hdn2014 about 10 years ago

Hi,

I am running lighttpd 1.4.35 (ssl) under RHEL6.5 using Python 2.6.6. In "lighttpd.conf", I tried to change "server.max-request-size" to one of these 3 possible values (btw 3145728=3gb):

#server.max-request-size = 0
server.max-request-size = 0
server.max-request-size = 3145728

To test, I am using this "index.html":
<html><body>
<form enctype="multipart/form-data" action="cgi-bin/save_file.py" method="post">
<p>File: <input type="file" name="file"></p>
<p><input type="submit" value="Upload"></p>
</form>
</body></html>

and upload script "save_file.py":
#!/usr/bin/env python
import cgi, os
import cgitb
cgitb.enable()
form = cgi.FieldStorage()
fileitem = form['file']
if fileitem.filename:
        fn = os.path.basename(fileitem.filename)
        open('/var/www/lighttpd/files/' + fn, 'wb').write(fileitem.file.read())
        message = 'The file "' + fn + '" was uploaded successfully'
else:
        message = 'No file was uploaded'
print """\
Content-Type: text/html\n
<html><body>
<p>%s</p>
</body></html>

and added these lines to "lighttpd.conf" to add cgi support:
server.modules += ("mod_cgi")
$HTTP["url"] =~ "^/cgi-bin/" {
    cgi.assign = (".py" => "/usr/bin/python")
}

There is no problem uploading any file smaller than 2GB but when I tried to upload a 2GB+ file, the browser (Firefox, IE) immediately aborted with this error:
The connection was reset
The connection to the server was reset while the page was loading.

Am I missing anything besides setting the "server.max-request-size" parameter? Btw, I tried to do this in Ubuntu 14.04 (with commented out "#server.max-request-size") and have no problem uploading the same file (2.5gb). Lighttpd log files did not show any error.

Any help would be greatly appreciated. I struggled for many hours on this. Google'ing but didn't see anyone with similar issue and/or solution.

Thanks!


Replies (2)

RE: Unable to upload file larger than 2gb - Added by stbuehler about 10 years ago

There is an SSIZE_MAX hard limit, which on 32-bit is 2GB (minus 1).

Also I hope you know what you're doing, because requiring large upload sizes like this sounds crazy.

RE: [Solved] Unable to upload file larger than 2gb - Added by gstrauss about 4 years ago

Fixed in lighttpd many years ago in lighttpd 1.4.44, using off_t for Content-Length.

    (1-2/2)