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提交数据
Linux 基础命令-CURL 表单上传文件的更多相关文章
- django 基于form表单上传文件和基于ajax上传文件
一.基于form表单上传文件 1.html里是有一个input type="file" 和 ‘submit’的标签 2.vies.py def fileupload(request ...
- java模拟表单上传文件,java通过模拟post方式提交表单实现图片上传功能实例
java模拟表单上传文件,java通过模拟post方式提交表单实现图片上传功能实例HttpClient 测试类,提供get post方法实例 package com.zdz.httpclient; i ...
- Express下使用formidable实现POST表单上传文件并保存
Express下使用formidable实现POST表单上传文件并保存 在上一篇文章中使用formidable实现了上传文件,但没将它保存下来. 一开始,我也以为是只得到了文件的相关信息,需要用fs. ...
- 巨蟒python全栈开发django11:ajax&&form表单上传文件contentType
回顾: 什么是异步? 可以开出一个线程,我发出请求,不用等待返回,可以做其他事情. 什么是同步? 同步就是,我发送出了一个请求,需要等待返回给我信息,我才可以操作其他事情. 局部刷新是什么? 通过jq ...
- vue form表单上传文件
<script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js">< ...
- 使用form表单上传文件
在使用form表单上传文件时候,input[type='file']是必然会用的,其中有一些小坑需要避免. 1.form的 enctype="multipart/form-data" ...
- from 表单上传文件和下载?
from表单上传单个文件的方法. 分为三个部分,简单演示. 一部分 表单上传文件 <%-- Created by IntelliJ IDEA. User: Administrator Date: ...
- JsonResponse类的使用、form表单上传文件补充、CBV和FBV、HTML的模板语法之传值与过滤器
昨日内容回顾 Django请求生命周期 # 1.浏览器发起请求 到达Django的socket服务端(web服务网关接口) 01 wsgiref 02 uwsgi + nginx 03 WSGI协议 ...
- libcurl提交表单上传文件
不多说了,curl的http上传文件代码示例,有需要的可以参考. int http_post_file(const char *url, const char *user, const char *p ...
随机推荐
- 【sublime xftp插件】 Host key verification failed ,错误处理
错误背景: 1.CentOS7上面作为运行环境,Coding在本机的windows环境 2.在windows上安装sublime 3,然后保存代码通过xftp保存到centos7虚机上面. 3.Cen ...
- vim 使用
vim有三种模式:输入模式,命令模式,底行模式,使用esc进入命令模式,在命令模式下按英文的冒号,进入底行模式:命令行模式下按i进入输入模式.vim编辑文件是将文件内容复制到缓冲区显示在屏幕上. vi ...
- Android笔记:反向横屏
1: 在manifest文件中更改android:screenOrientation="landscape"为“reverseLandscape” 2: 更改Android源码 3 ...
- POJ2104 K-th Number(归并树)
平方分割一直TLE,最后用归并树处理过了,使用STL会比较慢. #include<cstdio> #include<iostream> #include<cstdlib& ...
- Fzu2124 - 吃豆人 BFS
Description 吃豆人是一款非常经典的游戏,游戏中玩家控制吃豆人在地图上吃光所有豆子,并且避免被怪物抓住. 这道题没有怪物,将游戏的画面分成n*m的格子,每格地形可能为空地或者障碍物,吃豆人可 ...
- asp.net c# 网上搜集面试题目大全(附答案)
1.String str=new String("a")和String str = "a"有什么区别? String str = "a"; ...
- pandas 学习(1): pandas 数据结构之Series
1. Series Series 是一个类数组的数据结构,同时带有标签(lable)或者说索引(index). 1.1 下边生成一个最简单的Series对象,因为没有给Series指定索引,所以此时会 ...
- CI框架如何在主目录application目录之外使用uploadify上传插件和bootstrap前端框架:
19:29 2016/3/10CI框架如何在主目录application目录之外使用uploadify上传插件和bootstrap前端框架:项目主路径:F:\wamp\www\graduationPr ...
- mssql 获取自增列起始及增量
--首先创建一个表 CREATE TABLE [dbo].[abcd]( ,) NOT NULL, ) NULL, ) NULL ) ON [PRIMARY] --获取起始值 SELECT IDENT ...
- Hibernate学习笔记5
hql语句的查询(hibernate query language) hql和sql语句的区别sql:语言关系型数据库里面的通用查询,结构化查询语言,查看的是表以及表的列hql是hibernate中独 ...