zoukankan      html  css  js  c++  java
  • Linux 基础命令-CURL 表单上传文件

    CURL

    -F, --form <name=content>
    (HTTP) This lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using the Content-Type multipart/form-
    data according to RFC 2388. This enables uploading of binary files etc. To force the 'content' part to be a file, prefix the file name with an @ sign. To just get
    the content part from a file, prefix the file name with the symbol <. The difference between @ and < is then that @ makes a file get attached in the post as a
    file upload, while the < makes a text field and just get the contents for that text field from a file.

    Example, to send your password file to the server, where 'password' is the name of the form-field to which /etc/passwd will be the input:

    curl -F password=@/etc/passwd www.mypasswords.com

    To read content from stdin instead of a file, use - as the filename. This goes for both @ and < constructs.

    You can also tell curl what Content-Type to use by using 'type=', in a manner similar to:

    curl -F "web=@index.html;type=text/html" url.com

    or

    curl -F "name=daniel;type=text/foo" url.com

    You can also explicitly change the name field of a file upload part by setting filename=, like this:

    curl -F "file=@localfile;filename=nameinpost" url.com

    If filename/path contains ',' or ';', it must be quoted by double-quotes like:

    curl -F "file=@"localfile";filename="nameinpost"" url.com

    or

    curl -F 'file=@"localfile";filename="nameinpost"' url.com

    Note that if a filename/path is quoted by double-quotes, any double-quote or backslash within the filename must be escaped by backslash.

    See further examples and details in the MANUAL.

    This option can be used multiple times.

    (1)文件上传,Html 表单上传方式:
    <form name="form1" method="post" enctype="multipart/form-data" action="http://www.a.com/file">
    <div>
    <label for="caption">AppId:</label>
    <input id="AppId" onblur="javascript:updateAction();" type="text" value="cfttest"/>
    </div>
    <div>
    <label for="image1">上传文件:</label>
    <input name="filedata" type="file" />
    </div>
    <div>
    <label for="image1">上传类型:</label>
    <select id="uptype" name="uptype">
    <option value="0">唯一</option>
    <option value="1">覆盖</option>
    </select>
    </div>
    <div>
    <input type="submit" name="upload" value="上传" />
    </div>
    </form>

    (2).curl --form upload=@a41.zip --form uptype=1 http://www.a.com/file

    (3).curl -F "file=@a41.txt;filename=testaaabcd.txt" http://www.a.com/file

    上传文件,文件名称:testaaabcd.txt

    Post提交数据

     curl -d "b=20&t=b7693b96e99" http://api.web.com/Api/getList
     
    下载文件:

    curl -o ss -H"Host:www.file.com" http://1.1.1.1/file/123.jpg

    http://blog.csdn.net/xifeijian/article/details/9367339

  • 相关阅读:
    Chrome浏览器设置默认编码
    linux上安装subversion
    详解Linux命令行下常用svn命令
    css 使容器宽度适应内容宽
    Windsor Spring
    T4 Generate POCO Class for MSSQ
    MSSQ 树型结构数据 循环操作
    System.Reflection.Emit 动态实现接口
    T4 SqlSugar MySql
    微信多开
  • 原文地址:https://www.cnblogs.com/shouwu/p/6224916.html
Copyright © 2011-2022 走看看