憋半天憋出这么点代码来,暂时凑合可以用。。。需要手动删除文件末尾的分隔符,还有一个windows 换行:
#!/bin/bash newline="" while true; do read newline line_start=$(expr substr "$newline" 1 6) if [ ${line_start}x == "------x" ];then echo "Got the boundary" #just throw the follow lines away read newline read newline read newline toFile=new.tar.gz cat >$toFile fi done
暂时先这样吧,有空再做仔细点。
PS: 按上面代码接受 tar.gz 之后,tar 是可以正常解压的,然后提示:
gzip: stdin: decompression OK, trailing garbage ignored
然而并没有任何问题,就是说 gzip 没当这是个事。
if [ "${line_start}x" == "Content-Lengthx" ];then echo "Content-Length seg. is found" length=$(echo $newline|sed ‘s/[^0-9]//g‘)
HTML 代码用的是这个:
<meta http-equiv=Content-Type content="text/html;charset=utf-8"> <html> <body> <form enctype="multipart/form-data" action="http://localhost/UploadFile" method="post"> file1:<input type="file" name="file1"><br> <input type="submit" value="上传"> <input type="reset" value="重置"> </form> </body> </html>
时间: 2024-11-03 13:21:03