{"id":53000,"date":"2024-12-03T12:29:59","date_gmt":"2024-12-03T04:29:59","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53000\/"},"modified":"2024-12-03T12:29:59","modified_gmt":"2024-12-03T04:29:59","slug":"%e5%8f%91%e9%80%81-form-data-%e6%97%b6%ef%bc%8cboundary-%e7%9a%84%e5%a4%84%e7%90%86%ef%bc%9a%e6%b5%8f%e8%a7%88%e5%99%a8%e8%87%aa%e5%8a%a8%e8%ae%be%e7%bd%ae%e8%bf%98%e6%98%af%e6%89%8b%e5%8a%a8%e8%ae%be","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53000\/","title":{"rendered":"\u53d1\u9001 Form-Data \u65f6\uff0cBoundary \u7684\u5904\u7406\uff1a\u6d4f\u89c8\u5668\u81ea\u52a8\u8bbe\u7f6e\u8fd8\u662f\u624b\u52a8\u8bbe\u7f6e\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u53d1\u9001 Form-Data \u65f6\uff0cBoundary \u7684\u5904\u7406\uff1a\u6d4f\u89c8\u5668\u81ea\u52a8\u8bbe\u7f6e\u8fd8\u662f\u624b\u52a8\u8bbe\u7f6e\uff1f<\/h1>\n<p>\u6587\u7ae0\u5c0f\u767d\u4e00\u679a\uff0c\u6b63\u5728\u4e0d\u65ad\u5b66\u4e60\u79ef\u7d2f\u77e5\u8bc6\uff0c\u73b0\u5c06\u5b66\u4e60\u5230\u7684\u77e5\u8bc6\u8bb0\u5f55\u4e00\u4e0b\uff0c\u4e5f\u662f\u5c06\u6211\u7684\u6240\u5f97\u5206\u4eab\u7ed9\u5927\u5bb6\uff01\u800c\u4eca\u5929\u8fd9\u7bc7\u6587\u7ae0\u300a\u53d1\u9001 Form-Data \u65f6\uff0cBoundary \u7684\u5904\u7406\uff1a\u6d4f\u89c8\u5668\u81ea\u52a8\u8bbe\u7f6e\u8fd8\u662f\u624b\u52a8\u8bbe\u7f6e\uff1f\u300b\u5e26\u5927\u5bb6\u6765\u4e86\u89e3\u4e00\u4e0b##content_title##\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01<\/p>\n<p><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241125\/173252092667442bde4c3e9.jpg\" class=\"aligncenter\" title=\"\u53d1\u9001 Form-Data \u65f6\uff0cBoundary \u7684\u5904\u7406\uff1a\u6d4f\u89c8\u5668\u81ea\u52a8\u8bbe\u7f6e\u8fd8\u662f\u624b\u52a8\u8bbe\u7f6e\uff1f\u63d2\u56fe\" alt=\"\u53d1\u9001 Form-Data \u65f6\uff0cBoundary \u7684\u5904\u7406\uff1a\u6d4f\u89c8\u5668\u81ea\u52a8\u8bbe\u7f6e\u8fd8\u662f\u624b\u52a8\u8bbe\u7f6e\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u53d1\u9001 form-data \u65f6\uff0cboundary \u7684\u5904\u7406\u4e0e\u8bbe\u7f6e<\/strong><\/p>\n<p>\u5728\u53d1\u9001 form-data \u6570\u636e\u65f6\uff0cboundary \u662f\u6d4f\u89c8\u5668\u81ea\u52a8\u8bbe\u7f6e\u7684\u5417\uff1f<\/p>\n<p><strong>\u7b54\u6848\uff1a<\/strong><\/p>\n<p>\u662f\u7684\uff0c\u6d4f\u89c8\u5668\u4f1a\u81ea\u52a8\u8bbe\u7f6e boundary\u3002<\/p>\n<p><strong>\u53ef\u4ee5\u624b\u52a8\u8bbe\u7f6e boundary \u5417\uff1f<\/strong><\/p>\n<p>\u4e0d\u9700\u8981\uff0c\u6d4f\u89c8\u5668\u4f1a\u81ea\u52a8\u8865\u5168\u3002<\/p>\n<p><strong>\u53d1\u9001\u524d\u80fd\u5426\u83b7\u53d6 boundary \u7684\u503c\u662f\u4ec0\u4e48\uff1f<\/strong><\/p>\n<p>\u6d4f\u89c8\u5668\u4f1a\u81ea\u52a8\u751f\u6210\u7684 boundary \u503c\uff0c\u65e0\u9700\u624b\u52a8\u83b7\u53d6\u3002\u5982\u679c\u9700\u8981\u67e5\u770b boundary \u503c\uff0c\u53ef\u4ee5\u67e5\u770b\u6d4f\u89c8\u5668\u5f00\u53d1\u8005\u5de5\u5177\u4e2d\u7684 network \u9009\u9879\u5361\uff0c\u5728 request headers \u4e2d\u627e\u5230 content-type \u5934\u90e8\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u4ee5\u4e0b jquery.ajax() \u4ee3\u7801\u793a\u4f8b\u4e2d\uff0ccontenttype \u8bbe\u7f6e\u4e3a &#8220;multipart\/form-data;boundary=xxx&#8221;\uff1a<\/p>\n<pre>$.ajax({\n  type: \"post\",\n  url: \"\/login\",\n  data: formData,\n  success: function (res) {\n  },\n  processData: false,\n  contentType: \"multipart\/form-data;boundary=xxx\",\n  error: function (xhr) {\n    console.log(xhr);\n  },\n});<\/pre>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6307\u5b9a contenttype \u53ef\u80fd\u4f1a\u5bfc\u81f4\u540e\u7aef\u89e3\u6790\u8bf7\u6c42\u65f6\u51fa\u73b0\u95ee\u9898\u3002\u5efa\u8bae\u5c06 contenttype \u8bbe\u7f6e\u4e3a false\uff0c\u4ee5\u8ba9\u6d4f\u89c8\u5668\u81ea\u52a8\u5904\u7406 boundary\u3002<\/p>\n<p>\u672c\u7bc7\u5173\u4e8e\u300a\u53d1\u9001 Form-Data \u65f6\uff0cBoundary \u7684\u5904\u7406\uff1a\u6d4f\u89c8\u5668\u81ea\u52a8\u8bbe\u7f6e\u8fd8\u662f\u624b\u52a8\u8bbe\u7f6e\uff1f\u300b\u7684\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\u5566\uff0c\u4f46\u662f\u5b66\u65e0\u6b62\u5883\uff0c\u60f3\u8981\u4e86\u89e3\u5b66\u4e60\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   MySQL \u4e2d\u7684 UTF8MB4 \u662f\u5b9a\u957f\u5b58\u50a8\u5417\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u53d1\u9001 Form-Data \u65f6\uff0cBoundary \u7684\u5904\u7406\uff1a\u6d4f\u89c8\u5668\u81ea\u52a8\u8bbe\u7f6e\u8fd8\u662f\u624b\u52a8\u8bbe\u7f6e\uff1f \u6587\u7ae0\u5c0f\u767d\u4e00\u679a\uff0c\u6b63\u5728\u4e0d\u65ad\u5b66\u4e60\u79ef\u7d2f\u77e5\u8bc6\uff0c\u73b0\u5c06\u5b66\u4e60\u5230\u7684\u77e5\u8bc6\u8bb0\u5f55\u4e00\u4e0b\uff0c\u4e5f\u662f\u5c06\u6211\u7684\u6240\u5f97\u5206\u4eab\u7ed9\u5927\u5bb6\uff01\u800c\u4eca\u5929\u8fd9\u7bc7\u6587\u7ae0\u300a\u53d1\u9001 Form-Data \u65f6\uff0cBoundary \u7684\u5904\u7406\uff1a\u6d4f\u89c8\u5668\u81ea\u52a8\u8bbe\u7f6e\u8fd8\u662f\u624b\u52a8\u8bbe\u7f6e\uff1f\u300b\u5e26\u5927\u5bb6\u6765\u4e86\u89e3\u4e00\u4e0b##content_title##\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01 \u53d1\u9001 form-data \u65f6\uff0cboundary \u7684\u5904\u7406\u4e0e\u8bbe\u7f6e \u5728\u53d1\u9001 form-data \u6570\u636e\u65f6\uff0cboundary \u662f\u6d4f\u89c8\u5668\u81ea\u52a8\u8bbe\u7f6e\u7684\u5417\uff1f \u7b54\u6848\uff1a \u662f\u7684\uff0c\u6d4f\u89c8\u5668\u4f1a\u81ea\u52a8\u8bbe\u7f6e boundary\u3002 \u53ef\u4ee5\u624b\u52a8\u8bbe\u7f6e boundary \u5417\uff1f \u4e0d\u9700\u8981\uff0c\u6d4f\u89c8\u5668\u4f1a\u81ea\u52a8\u8865\u5168\u3002 \u53d1\u9001\u524d\u80fd\u5426\u83b7\u53d6 boundary \u7684\u503c\u662f\u4ec0\u4e48\uff1f \u6d4f\u89c8\u5668\u4f1a\u81ea\u52a8\u751f\u6210\u7684 boundary \u503c\uff0c\u65e0\u9700\u624b\u52a8\u83b7\u53d6\u3002\u5982\u679c\u9700\u8981\u67e5\u770b boundary \u503c\uff0c\u53ef\u4ee5\u67e5\u770b\u6d4f\u89c8\u5668\u5f00\u53d1\u8005\u5de5\u5177\u4e2d\u7684 network \u9009\u9879\u5361\uff0c\u5728 request headers \u4e2d\u627e\u5230 content-type \u5934\u90e8\u3002 \u793a\u4f8b\uff1a \u4ee5\u4e0b jquery.ajax() \u4ee3\u7801\u793a\u4f8b\u4e2d\uff0ccontenttype \u8bbe\u7f6e\u4e3a &#8220;multipart\/form-data;boundary=xxx&#8221;\uff1a $.ajax({ type: &#8220;post&#8221;, url: &#8220;\/login&#8221;, data: formData, success: function (res) { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-53000","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53000","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=53000"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53000\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}