My own personal website.
上传图片等资源时注意表单的enctype 值设为multipart/form-data
05-27-2020 / 1 min read

上传图片等资源时注意表单的enctype 值设为multipart/form-data ,不然后台很可能收不到和文本内容一起提交上来的图片等数据资源。
参考: MIME 类型|MDN

When the value of the method attribute is post, enctype is the MIME type of content that is used to submit the form to the server. Possible values are:

application/x-www-form-urlencoded: The default value if the attribute is not specified.
multipart/form-data: The value used for an <input> element with the type attribute set to "file".
text/plain: (HTML5)
This value can be overridden by a formenctype(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formenctype) attribute on a <button> or <input> element