您现在的位置是:网站首页>软件开发>开发终端>uni-appuni-app

前端使用uni.uploadFile发生表单数据时,后端通过$_POST/param()等方法都获取不到

风口下的猪2021-11-06uni-app

简介

后端通过halt打印结果

 array:3 [
  "------WebKitFormBoundaryoANcOgIw49OcaFrf\r\nContent-Disposition:_form-data;_name" => """
    "name"\r\n
    \r\n
    张三\r\n
    ------WebKitFormBoundaryoANcOgIw49OcaFrf\r\n
    Content-Disposition: form-data; name="image"; filename="file-1636177502249"\r\n
    Content-Type: text/html\r\n
    \r\n
    <!DOCTYPE html>\n
    <html lang="zh-CN">\n
    \n
        <head>\n
            <meta charset="utf-8">\n
            <meta http-equiv="X-UA-Compatible" content="IE=edge">\n
            <title>\n
                orderManeger\n
            </title>\n
            <script>\n
                var coverSupport = 'CSS' in window 
    """
  "typeof_CSS_supports_" => "== 'function' "
  "(CSS_supports('top:_env(a)')_||_CSS_supports('top:_constant(a)'))\n____________document_write('<meta_name" => """
    "viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0'   (coverSupport ? ', viewport-fit=cover' : '')   '" />')\n
            </script>\n
            <link rel="stylesheet" href="/static/index.9ffdaeb8.css" />\n
        </head>\n
    \n
        <body>\n
            <noscript>\n
                <strong>Please enable JavaScript to continue.</strong>\n
            </noscript>\n
            <div id="app"></div>\n
            <!-- built files will be auto injected -->\n
        <script type="text/javascript" src="/static/js/chunk-vendors.js"></script><script type="text/javascript" src="/static/js/index.js"></script></body>\n
    \n
    </html>\n
            <script>\n
            (function () {\r\n
      var userAgent = navigator.userAgent\r\n
      window.addEventListener('resize', function () {\r\n
        if (navigator.userAgent !== userAgent) {\n
          /* eslint-disable no-undef */\r\n
          location.reload()\r\n
        }\r\n
      })\r\n
    })()\n
    \n
            </script>\n
            \r\n
    ------WebKitFormBoundaryoANcOgIw49OcaFrf--\r\n
    """
]


原来是前端接口封装时,声明其header内容

'Content-Type':'application/x-www-form-urlencoded'


注意,表单提交不要声明content-type




很赞哦! (0)

  • 软件开发
  • 素质要求
  • 计算机基础
  • 架构
  • 安全
  • 性能
  • 运维
  • 尾页
  • 数据库
  • 开发终端
  • 语言基础
  • 项目管理
  • 产品设计
  • 系统
  • 工作规范
  • 计算机网络
  • 前端技术栈
  • 数据结构
  • 计算机组成原理
  • 后端技术栈
  • 性能优化
  • 安全设计
  • 常见模块
  • 计算机操作系统
  • 服务器
  • python
  • MySQL
  • thinkphp
  • PHP
  • Java
  • JavaScript
  • Windows
  • Linux
  • 特效
  • indexedDB
  • vue
  • 淘宝联盟
  • Ionic
  • Angular
  • 微信小程序
  • 支付宝小程序
  • uni-app
  • css/sass/less
  • 支付
  • socket
  • 爬虫
  • web性能优化
  • 消息推送
  • CVM
  • sqlite
  • Redis
  • 前端基础
  • 基础
  • element
  • Nginx
  • yii2
  • /ponder/index.php/index/catelist/catelist/cateid/10.html

    相关阅读 (同一栏目)

    << /

    标签云

    站点信息

    • 文章统计:528篇
    • 移动端访问:扫码进入SQ3R