HTTP file upload using BASH as CGI

Source: Internet
Author: User
Tags http file upload

Suppress half a day to suppress such a bit of code, temporarily make it possible to use ... You need to manually delete the delimiter at the end of the file, as well as a newline of windows:

#!/bin/Bashnewline="" while true; DoRead newline Line_start=$(ExprSubstr"$newline" 1 6)    if[${line_start}x = ="------x"]; Then        Echo "Got theBoundary"#just Throw the follow lines away read newline read newline read newline tofile=new.Tar. GZCat>$toFilefi Done

Let's do this for the time being, and be more careful when you are free.

PS: After accepting tar.gz according to the above code, TAR can be decompressed normally, then prompt:

Gzip:stdin:decompression OK, trailing garbage ignored
However, there is no problem, that is, Gzip did not when this is a thing.

    if " ${line_start}x " " Content-lengthx " ];  then        Echo " content-length seg. is found "         length=$ (echo $newline |  Sed's/[^0-9]//g')

The HTML code uses this:

<Metahttp-equiv=content-typecontent= "Text/html;charset=utf-8"><HTML><Body><formenctype= "Multipart/form-data"Action= "Http://localhost/UploadFile"Method= "POST">file1:<inputtype= "File"name= "File1"><BR><inputtype= "Submit"value= "Upload"><inputtype= "Reset"value= "Reset"></form></Body></HTML> 

HTTP file upload using BASH as CGI

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.