httpd and form-based upload
Alexander Kriegisch
Alexander at Kriegisch.name
Sun Feb 4 13:44:40 UTC 2007
I wrote earlier:
>> I would like to know if httpd supports form-based uploads and how
>> they can be handled in plain shell scripts (/bin/sh). I would be glad
>> to see one or more sample script(s).
Some more background info: An HTML page for form-based upload could look like this:
<html>
<body>
<form action="/cgi-bin/do_upload.cgi" method=post enctype="multipart/form-data">
<input type=file size=50 maxlength=100000 name="File"><br>
<input type=submit value="Submit">
</form>
</body>
</html>
A server-side script receiving the upload could look like this:
#!/bin/sh
echo -n -e 'HTTP/1.0 200 OK\r\n'
echo -n -e 'Content-type: text/html\r\n\r\n'
cat > /var/tmp/upload.bin
cat << EOF
<html>
<body>
<h2>Upload finished</h2>
</body>
</html>
EOF
And this would be the content of upload.bin:
-----------------------------7d72033ac0372
Content-Disposition: form-data; name="File"; filename="I:\install\sample_upload.tar.gz"
Content-Type: application/x-gzip
(...) unencoded binary stuff (...)
-----------------------------7d72033ac0372--
So, basically, I would need a shell script which could
cut away the MIME header and footer, so as to only save
the "unencoded binary stuff" section to disk. This may
not be a very busybox-specific question, but anyway,
probably I should use the limited means provided by
busybox's shell (ash) and toolset (sed, awk, maybe others)
to achieve. I was also hoping for an httpd configuration
option to help me achieve my goal without having to code
a CGI upload handler in C. BTW: My busybox is running on
a DSL router.
--
Alexander Kriegisch
More information about the busybox
mailing list