• form编码方式application/x-www-form-urlencoded和multipart/form-data的区别


    form元素有个enctype属性,可以指定数据编码方式,有如下三种:

    1. application/x-www-form-urlencoded: 表单数据编码为键值对,&分隔

    2. multipart/form-data: 表单数据编码为一条消息,每个控件对应消息的一部分

    3. text/plain: 表单数据以纯文本形式进行编码

    详细说明:

    form的enctype的编码方式,常用有两种:

    application/x-www-form-urlencoded和multipart/form-data

    其中 application/x-www-form-urlencoded为默认编码方式。

    在form的action为get时,浏览器用x-www-form-urlencoded的编码方式,将表单数据编码为
    (name1=value1&name2=value2...),然后把这个字符串append到url后面,用?分隔,跳转
    到这个新的url

    当form的action为post时,浏览器将form数据封装到http body中,然后发送到server。

    在没有type=file时候,用默认的 application/x-www-form-urlencoded 就行。

    在有 type=file 时候,要用multipart/form-data编码方式。浏览器会把表单以控件为单位分割,
    并且为每个部分加上Content-Dispositon(form-data或file)、Content-Type(默认text/plain)、
    name(控件name)等信息,并加上分割符(boundary)。

  • 相关阅读:
    Django ListView实现分页
    redis-pipeline
    MRO
    进程状态
    ORM基本操作回顾
    协程回顾
    线程的回顾
    multiprocessing- 基于进程的并行性
    Fix Curl client hung issue
    Curl request 'Expect: 100-Continue' Issues and Risks
  • 原文地址:https://www.cnblogs.com/mengff/p/7282488.html
Copyright © 2020-2023  润新知