我正在尝试制作一个 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.
是的
为什么?在请求到达您的服务器之前,您无法编辑 header 信息。那么还有什么意义吗?Also, the reason that I am interested in this is because I wanted to edit(Add) some of the information in 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/