lighttpd 1.4.19 on Ubuntu: http file uploads fail

I have a Linode 540 with ubuntu, lighttypd 1.4.19, php-cgi. File uploads are not working. Firefox says: "The connection to the server was reset while the page was loading."

I am trying to import a compressed exported database into phpmyadmin. This is what /var/log/lightty/access.log has:

71.170.222.197 - - [25/Sep/2008:16:56:02 -0400] "POST /phpmyadmin/import.php HTTP/1.1" 413 0 "http://www.krueckeberg.org/phpmyadmin/s … 4eb0f267c8">http://www.krueckeberg.org/phpmyadmin/server_import.php?token=5d7d9370cfbd84cd1fa6e74eb0f267c8" "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1"

This is what /var/log/lighttpd/error.log has.

2008-09-25 16:56:01: (connections.c.1102) denying upload as opening to temp-file for upload failed: /var/cache/lighttpd/uploads/lighttpd-upload-Hu0l6j No such file or directory

2008-09-25 16:56:02: (connections.c.1102) denying upload as opening to temp-file for upload failed: /var/cache/lighttpd/uploads/lighttpd-upload-jjFSNv No such file or directory

2008-09-25 16:56:02: (connections.c.1102) denying upload as opening to temp-file for upload failed: /var/cache/lighttpd/uploads/lighttpd-upload-NbEhtS No such file or directory

2008-09-25 16:56:02: (connections.c.1102) denying upload as opening to temp-file for upload failed: /var/cache/lighttpd/uploads/lighttpd-upload-zxv3Gq No such file or directory

2008-09-25 16:56:02: (connections.c.1102) denying upload as opening to temp-file for upload failed: /var/cache/lighttpd/uploads/lighttpd-upload-HG2Qx7 No such file or directory

The file size of the is 4,164KB. I wrote a small php script (to upload files) to help "debug" this problem. Upload only worked with small text files.

Any help is appreciated. I getting very tempted to switch to Debian.

11 Replies

Actually the file size is only 195KB.

Well it smells like a permission problem between your web server credentials and your /var/cache/lighttpd paths. But you say you got smaller uploads to work… maybe your setting of uploadmaxfilesize in php.ini is too small?

No, it was definitely not an uploadmaxfilesize problem. I bumped uploadmaxfilesize up to 20M without success. And I have postmaxsize=10M.

The problem was the uploads directory did not exist in /var/cache/lighttpd/. Doing

mkdir /var/cache/lighttpd/uploads
chowm -R www-data:www-data /var/cache/lighttpd/uploads/

has seemed to fix the problem. I just don't get why the uploads subdir wasn't automatically created by lighttpd?

Very few software products that I know of will create needed directories on the fly based on an entry in a config file. It is much more common to be required to make the directories your self, to save you from screwing up your config file and doing something you really didn't mean to do.

I know what your saying. But something must be amiss in the installation because an upload directory will always be needed by a http server because file upload forms are part of http. The fact that I simply copied the lighttpd.conf from a prior Debian/Etch installation on a different vps could have had something to do with this problem (but I don't see how).

Anyway, the replies are much appreciated.

@kurtk:

But something must be amiss in the installation because an upload directory will always be needed by a http server because file upload forms are part of http.
Nope.

The PUT method (to replace a URL) is defined by the HTTP 1.1, but most servers don't support it at all (except to deny it). The POST method sends an entity to the server, but how that entity is processed is determined by the URL: could be a file upload, could be a form values, could be a Python script to run, could be ignored completely: all equally valid and all completely outside the scope of HTTP.

Forms are part of HTML, and the INPUT type 'file' is intended for uploads, but there's no requirement that the server accept such uploads, nor should there be (remember: I can send arbitrary requests to your server, regardless of what forms you may or may not present me.) As someone who has run many servers that didn't accept file uploads, I'd be pretty unhappy with an HTTP daemon that enabled them automatically.

What you say makes sense. So I changed php.ini so that

uploadtmpdir="/home/lighttpd/uploads"

Set the directory's group to www-data and gave it rw permissions. I had php process a http file form. It worked fine.

Thanks for info.

HTTP != HTML

HTTP is a communication protocol. HTML is a way of expressing the layout and content of a document for interpretation by a browser.

@SteveG:

@kurtk:

But something must be amiss in the installation because an upload directory will always be needed by a http server because file upload forms are part of http.
Nope.

The PUT method (to replace a URL) is defined by the HTTP 1.1, but most servers don't support it at all (except to deny it). The POST method sends an entity to the server, but how that entity is processed is determined by the URL: could be a file upload, could be a form values, could be a Python script to run, could be ignored completely: all equally valid and all completely outside the scope of HTTP.

Forms are part of HTML, and the INPUT type 'file' is intended for uploads, but there's no requirement that the server accept such uploads, nor should there be (remember: I can send arbitrary requests to your server, regardless of what forms you may or may not present me.) As someone who has run many servers that didn't accept file uploads, I'd be pretty unhappy with an HTTP daemon that enabled them automatically.

Yikes. I didn't even realize I had written HTTP instead of HTML.

@mwalling:

HTTP != HTML

HTTP is a communication protocol. HTML is a way of expressing the layout and content of a document for interpretation by a browser.

Yes, I know. That's why I discussed them in two separate paragraphs :-)

I know, I was repeating what you said for his benefit :)
@kurtk:

I had php process a http file form.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct