Unable to Upload File using POST Method -httpd-busybox-busybox-1.00-pre10

Hiroshi Ito ito at mlb.co.jp
Tue Apr 15 11:10:08 UTC 2008


Hello,

my busybox says, "BusyBox v1.00 (2005.01.07-11:17+0000)".
and it able to upload tar.gz file.

my cgi is busybox's ash shell script.
there are japanese text in there, so, I took some essential part from them.

form definition
----- receiveconf.cgi ----
#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin

cat << EOF

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=euc-jp">
</head>
<body  bgcolor="#ffffff" text="#0000aa" link="#ff0000" vlink="#ff5555" alink="#aaaaff" background="/djg158.gif" >
<P>
<center>

 --- some message here --

 <form name="form1" action="/cgi-bin/receivecgiconf2.cgi" METHOD="post" enctype="multipart/form-data">
 <input type="file" name="submitfile" />
<INPUT TYPE="submit" NAME="set" VALUE="--name of button--">
</form>
</center>
</body>
</html>
EOF
----- receiveconf.cgi ----



and  cgi for upload
----- receiveconf2.cgi ----
#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin

file=/tmp/$$
cat > $file
cat << EOF

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=euc-jp">
</head>
<body  bgcolor="#ffffff" text="#0000aa" link="#ff0000" vlink="#ff5555" alink="#aaaaff" background="/djg158.gif" >
<P>
EOF
skip=`sed '1{:a;s/\(name="*submitfile"*\)/\1/;t;n;ba;};/^.$/q' $file|wc -c`

# check for upload file is valid tar file.
if dd if=$file bs=1 skip=$((skip)) 2>/dev/null | tar ztf - etc/mld/mldbox.conf > /dev/null 2>&1; then
  cat << EOF
<center>
 --- good message here ---
</center>
</body>
</html>
EOF
doall()
{
  cd /
  dd if=$file bs=1 skip=$((skip)) 2>/dev/null | tar zxpf -
}

  doall < /dev/null > /dev/null 2>&1
else
  cat << EOF
<center>
 --- bad file message here ---
</center>
</body>
</html>
EOF
fi
rm -f $file >/dev/null 2>&1
----- receiveconf2.cgi ----

--------
Hiroshi Ito
Media Lab. Inc.,
URL http://www.mlb.co.jp ( Sorry, Japanese only. )
TEL +81-3-5294-7255  FAX +81-3-5294-7256



More information about the busybox mailing list