【问题标题】:Why on ajax postbacks form content-type can not be multipart/form-data?为什么 ajax 回发表单内容类型不能是多部分/表单数据?
【发布时间】:2011-09-09 14:37:51
【问题描述】:

我有一个页面,其中表单的内容类型设置为enctype="multipart/form-data"。该页面包含<input type="file" 标签和一个发布(启动上传)的按钮。两者都在通过 ajax 更新的面板内。单击该按钮会生成一个内容类型为application/x-www-form-urlencoded 的xmlhttp 请求。

基本上,当上传输入在通过 ajax 更新的容器内时,表单的 enctype 会被忽略。

有很多帖子说您不能使用 ajax 拥有 multipart/form-data。为什么是这样?

【问题讨论】:

    标签: html ajax content-type xmlhttprequest


    【解决方案1】:

    您可以创建多部分 POST 请求 - 请参阅:

    XMLHttpRequest POST multipart/form-data

    【讨论】:

      猜你喜欢
      • 2015-10-19
      • 2022-11-12
      • 2019-04-16
      • 1970-01-01
      • 2015-02-14
      • 2019-03-29
      • 2011-03-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多