php - enctype ="multipart/form-data"到底向服务器发送了什么信息?

标签 php upload multipartform-data

我正在尝试制作一个 php 脚本来上传文件。据我目前的了解,enctype="multipart/form-data"向 http 发送某种类型的 header 以使上传文件成为可能。现在我不知道这些信息到底是什么。无论如何,我可以回显或查看该头文件吗?另外,我对此感兴趣的原因是因为我想编辑(添加)标题中的一些信息。

基本上我想要的是每当用户从<input type="file"/>中选择一个文件时我想将其附加在 header 中,以便保存信息(我可能会使用 session 来存储这些信息)并且用户可以继续选择其他文件。我知道有<input type="file" multiple/>选择多个文件,但我要采用的方法有点不同。

提前致谢。

最佳答案

From my understanding so far, enctype="multipart/form-data" sends certain type of header to http to make uploading file possible.

是的

Also, the reason that I am interested in this is because I wanted to edit(Add) some of the information in header.

为什么?在请求到达您的服务器之前,您无法编辑 header 信息。那么还有什么意义吗?

Basically what I am going for is whenever a user selects a file from < input type="file"/ > I want to append it in the header so that the information is saved (I will probably use session to store those information)

仅当 <form> 时才发送数据已提交,则选中的文件全部为POST编辑

要允许无限数量的文件,您可以使用 <input type="file" name="attachment[]">并使用javascript允许用户添加附件。

还有很多非常好的 uploader 可用;

<input type="file" multiple/>仅HTML5支持,暂不推荐使用。

关于php - enctype ="multipart/form-data"到底向服务器发送了什么信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9244322/

相关文章:

php - 在 PHP 中比较 MySQL 日期字符串格式是否正确?

node.js - express req.body 为空

node.js - Nodejs 将 base64 字符串作为表单数据发布

php - 编译 Doctrine 作为 php 的扩展

javascript - 通过AJAX将PHP变量传递给另一个DIV中的PHP变量

http - 无法通过 Squid 代理测试基于 HTTP PUT 的文件上传

php - Javascript清除缓存图像

angular - 使用 Angular 4 将 zip 文件上传到 spring rest Controller

php - MySQL:有索引和小文件排序更好还是没有索引和文件排序更好?

jquery - 如何显示当前上传进度(jquery + post + php)?