Project

General

Profile

[Solved] Upload a file - POST - No Files found

Added by dkal almost 8 years ago

Hi,
I try to upload a file to my webserver using POST: I must be doing something completely wrong.
I am using:

Linux raspberrypi 4.1.13+ #826 PREEMPT Fri Nov 13 20:13:22 GMT 2015 armv6l GNU/Linux
lighttpd/1.4.31 (ssl) (Feb 23 2016 22:37:00) - a light and fast webserver

I created a html page:

<form method="POST" enctype="multipart/form-data" action="upload.cgi">
<input type="file" name="myfile">
<input type="submit" name="submit" value="Upload Now">
</form>

The cgi Script looks like this:
upload.cgi
echo oooo
env
ls -l /var/cache/lighttpd/uploads/
ls -l /var/tmp

My Config contains:
server.upload-dirs=( “/var/cache/lighttpd/uploads/ )

I did assume that this is there the uploaded file are temp. stored.
But the Output of my cgi Script shows nothing:
Output in Webbrowser:
oooo
HTTP_CONTENT_LENGTH=12171
HTTP_X_BLUECOAT_VIA=da4ce590b0f87f99
HTTP_USER_AGENT=Mozilla/5.0 (Windows NT 6.1; rv:46.0) Gecko/20100101 Firefox/46.0
HTTP_HOST=--------.strangled.net:8080
SERVER_PORT=80
DOCUMENT_ROOT=/var/www/cgi-bin/
SCRIPT_FILENAME=/var/www/cgi-bin/upload.cgi
REQUEST_URI=/cgi-bin/upload.cgi
SCRIPT_NAME=/cgi-bin/upload.cgi
HTTP_CONNECTION=Keep-Alive
REMOTE_PORT=49740
PWD=/var/www/cgi-bin
REDIRECT_STATUS=200
HTTP_ACCEPT_LANGUAGE=de,en-US;q=0.7,en;q=0.3
HTTP_REFERER=http://--------.strangled.net:8080/cgi-bin/i.html
HTTP_ACCEPT=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
REMOTE_ADDR=194.25.90.66
SHLVL=1
SERVER_NAME=--------.strangled.net
CONTENT_LENGTH=12171
SERVER_SOFTWARE=lighttpd/1.4.31
SERVER_ADDR=0.0.0.0
GATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.0
HTTP_ACCEPT_ENCODING=gzip, deflate
CONTENT_TYPE=multipart/form-data; boundary=---------------------------30281595916313
REQUEST_METHOD=POST
_=/usr/bin/env
total 0
total 0

(I replaced my dyn. hostname with -----) Any help what I need to change?
Thanks in advance Dirk


Replies (2)

RE: Upload a file - POST - No Files found - Added by gstrauss almost 8 years ago

A few things you might not aware of:
  • lighttpd does not use temporary files when the request body is small; it just keep the request body in memory
  • lighttpd passes the request body to the backend (e.g. CGI on stdin) and then removes the temporary file (if a temp file was used)

It is the responsibility of the script to handle the upload, whether it is multipart/form-data or some other encoding.
server.upload-dirs is for temporary files.

RE: Upload a file - POST - No Files found - Added by dkal almost 8 years ago

lighttpd passes the request body to the backend (e.g. CGI on stdin)
Thanks that solved the problem

    (1-2/2)