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

Linux 基础命令-CURL 表单上传文件的更多相关文章

  1. django 基于form表单上传文件和基于ajax上传文件

    一.基于form表单上传文件 1.html里是有一个input type="file" 和 ‘submit’的标签 2.vies.py def fileupload(request ...

  2. java模拟表单上传文件,java通过模拟post方式提交表单实现图片上传功能实例

    java模拟表单上传文件,java通过模拟post方式提交表单实现图片上传功能实例HttpClient 测试类,提供get post方法实例 package com.zdz.httpclient; i ...

  3. Express下使用formidable实现POST表单上传文件并保存

    Express下使用formidable实现POST表单上传文件并保存 在上一篇文章中使用formidable实现了上传文件,但没将它保存下来. 一开始,我也以为是只得到了文件的相关信息,需要用fs. ...

  4. 巨蟒python全栈开发django11:ajax&&form表单上传文件contentType

    回顾: 什么是异步? 可以开出一个线程,我发出请求,不用等待返回,可以做其他事情. 什么是同步? 同步就是,我发送出了一个请求,需要等待返回给我信息,我才可以操作其他事情. 局部刷新是什么? 通过jq ...

  5. vue form表单上传文件

    <script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js">< ...

  6. 使用form表单上传文件

    在使用form表单上传文件时候,input[type='file']是必然会用的,其中有一些小坑需要避免. 1.form的 enctype="multipart/form-data" ...

  7. from 表单上传文件和下载?

    from表单上传单个文件的方法. 分为三个部分,简单演示. 一部分 表单上传文件 <%-- Created by IntelliJ IDEA. User: Administrator Date: ...

  8. JsonResponse类的使用、form表单上传文件补充、CBV和FBV、HTML的模板语法之传值与过滤器

    昨日内容回顾 Django请求生命周期 # 1.浏览器发起请求 到达Django的socket服务端(web服务网关接口) 01 wsgiref 02 uwsgi + nginx 03 WSGI协议 ...

  9. libcurl提交表单上传文件

    不多说了,curl的http上传文件代码示例,有需要的可以参考. int http_post_file(const char *url, const char *user, const char *p ...

随机推荐

  1. MySQL 5.7 学习:安全相关特性

    背景: 继上次介绍 初识 MySQL 5.6 新功能.参数完之后,刚好MySQL 5.7又GA了,在官方测试里看到,MySQL5.7在功能.性能.可用性.安全和监控上又提升了很高.现在看看和MySQL ...

  2. javascript学习 真正理解DOM脚本编程技术背后的思路和原则

    本文学习来源于<javascriptDOM编程艺术>仅作笔记 学会怎样才能利用DOM脚本编程技术以一种既方便自己更体贴用户的方式去充实和完善你们的网页. 循序渐进:从最核心的内容开始,逐步 ...

  3. SQL IN ANY ,(all any) 区别

    EXITS 和 IN 的区别: 从效率来看: 1) select * from T1 where exists(select 1 from T2 where T1.a=T2.a) ; T1数据量小而T ...

  4. Cycles渲染研究测试效果图

    从左到右:.贴图镂空透明  2.纹理半透明  3.纹理  4.材质半透明  5.材质 输入输出节点信息如下: ############################################# ...

  5. Windows 8.1安装 Vmware10

    之前在windows 8上安装的Vmware 9.0,已经激活了用的蛮好,可是自从上次自动更新系统到windows 8.1后,启动虚拟机时提示要激活 使用各种激活码与注册机都无效,就算注册表信息丢失但 ...

  6. Xib中UIScrollView添加约束步骤

    要往scrollView里面添加子控件--从向往下排 0.设置scrollView的上下左右约束距离控制器view边距为零(确定frame的大小) 1.要往scrollView添加一个内容View 2 ...

  7. 移动端使用让图片或者div垂直居中

    ._limgMIiddle{ /* Firefox */ display:-moz-box; -moz-box-pack:center; -moz-box-align:center; /* Safar ...

  8. 【CentOS】又是一篇Shell

    一.Shell 1.Shell脚本的格式 #!/bin/bash 或者是 #!/bin/sh 开头 ,这是用于解析脚本的工具 2.执行脚本的方法 (1)bash filename 或者是sh file ...

  9. SubSonic指南中文版

    翻译:王鹏程张原 王伟策划:毛凌志2009年1月北京工业大学软件学院PS:有问题反馈至http://lexus.cnblogs.comGetting Started with SubSonicBy S ...

  10. Codeforces Round #354 (Div. 2)

    贪心 A Nicholas and Permutation #include <bits/stdc++.h> typedef long long ll; const int N = 1e5 ...