{"id":49378,"date":"2024-12-02T10:56:39","date_gmt":"2024-12-02T02:56:39","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49378\/"},"modified":"2024-12-02T10:56:39","modified_gmt":"2024-12-02T02:56:39","slug":"%e4%b8%8a%e4%bc%a0%e7%9a%84%e6%96%87%e4%bb%b6%e5%a6%82%e4%bd%95%e7%a7%bb%e5%8a%a8%e5%88%b0%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%8c%87%e5%ae%9a%e4%bd%8d%e7%bd%ae%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/49378\/","title":{"rendered":"\u4e0a\u4f20\u7684\u6587\u4ef6\u5982\u4f55\u79fb\u52a8\u5230\u670d\u52a1\u5668\u6307\u5b9a\u4f4d\u7f6e\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u4e0a\u4f20\u7684\u6587\u4ef6\u5982\u4f55\u79fb\u52a8\u5230\u670d\u52a1\u5668\u6307\u5b9a\u4f4d\u7f6e\uff1f<\/h1>\n<p>\u5c0f\u4f19\u4f34\u4eec\u5bf9\u6587\u7ae0\u7f16\u7a0b\u611f\u5174\u8da3\u5417\uff1f\u662f\u5426\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff1f\u5982\u679c\u662f\uff0c\u90a3\u4e48\u672c\u6587\u300a\u4e0a\u4f20\u7684\u6587\u4ef6\u5982\u4f55\u79fb\u52a8\u5230\u670d\u52a1\u5668\u6307\u5b9a\u4f4d\u7f6e\uff1f\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff0c\u672c\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\u3002\u5728\u4e4b\u540e\u7684\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u591a\u591a\u5206\u4eab\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241130\/1732974881674b19210882f.jpg\" class=\"aligncenter\" title=\"\u4e0a\u4f20\u7684\u6587\u4ef6\u5982\u4f55\u79fb\u52a8\u5230\u670d\u52a1\u5668\u6307\u5b9a\u4f4d\u7f6e\uff1f\u63d2\u56fe\" alt=\"\u4e0a\u4f20\u7684\u6587\u4ef6\u5982\u4f55\u79fb\u52a8\u5230\u670d\u52a1\u5668\u6307\u5b9a\u4f4d\u7f6e\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5c06\u4e0a\u4f20\u6587\u4ef6\u4ece input file \u590d\u5236\u5230\u5176\u4ed6\u4f4d\u7f6e<\/strong><\/p>\n<p>\u4e3a\u4e86\u590d\u5236\u4e0a\u4f20\u5230 input file \u4e2d\u7684\u6587\u4ef6\u5230\u5176\u4ed6\u4f4d\u7f6e\uff0c\u9700\u8981\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528 form \u8868\u5355\u4e0a\u4f20\u6587\u4ef6\uff1a<\/strong><\/p>\n<pre>&lt;form action='xx.php' method='post' enctype='multipart\/form-data'&gt;\n  &lt;input type='file' name='file'&gt;\n  &lt;input type='button' name='btn' value='upload'&gt;\n&lt;\/form&gt;<\/pre>\n<\/li>\n<li>\n<p><strong>\u63a5\u6536\u4e0a\u4f20\u6587\u4ef6\uff1a<\/strong><br \/>\u5728 php \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7 $_files \u6570\u7ec4\u83b7\u53d6\u4e0a\u4f20\u6587\u4ef6\u7684\u4fe1\u606f\uff1a<\/p>\n<pre>if (isset($_files['file'])) {\n  $file = $_files['file'];\n}<\/pre>\n<\/li>\n<li>\n<p><strong>\u79fb\u52a8\u4e0a\u4f20\u6587\u4ef6\uff1a<\/strong><br \/>\u4f7f\u7528 move_uploaded_file \u51fd\u6570\u5c06\u4e0a\u4f20\u6587\u4ef6\u79fb\u52a8\u5230\u6307\u5b9a\u4f4d\u7f6e\uff1a<\/p>\n<pre>$targetPath = '.\/1.jpg';\nmove_uploaded_file($file['tmp_name'], $targetPath);<\/pre>\n<\/li>\n<\/ol>\n<p>\u6b64\u64cd\u4f5c\u5c06\u4ece\u4e34\u65f6\u5b58\u50a8\u4f4d\u7f6e\u79fb\u52a8\u6587\u4ef6\u5230\u6307\u5b9a\u7684 $targetpath \u8def\u5f84\u3002\u8bf7\u786e\u4fdd\u8be5\u8def\u5f84\u5177\u6709\u9002\u5f53\u7684\u5199\u5165\u6743\u9650\u3002<\/p>\n<p>\u672c\u7bc7\u5173\u4e8e\u300a\u4e0a\u4f20\u7684\u6587\u4ef6\u5982\u4f55\u79fb\u52a8\u5230\u670d\u52a1\u5668\u6307\u5b9a\u4f4d\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","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u4f20\u7684\u6587\u4ef6\u5982\u4f55\u79fb\u52a8\u5230\u670d\u52a1\u5668\u6307\u5b9a\u4f4d\u7f6e\uff1f \u5c0f\u4f19\u4f34\u4eec\u5bf9\u6587\u7ae0\u7f16\u7a0b\u611f\u5174\u8da3\u5417\uff1f\u662f\u5426\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff1f\u5982\u679c\u662f\uff0c\u90a3\u4e48\u672c\u6587\u300a\u4e0a\u4f20\u7684\u6587\u4ef6\u5982\u4f55\u79fb\u52a8\u5230\u670d\u52a1\u5668\u6307\u5b9a\u4f4d\u7f6e\uff1f\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff0c\u672c\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\u3002\u5728\u4e4b\u540e\u7684\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u591a\u591a\u5206\u4eab\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff01 \u5982\u4f55\u5c06\u4e0a\u4f20\u6587\u4ef6\u4ece input file \u590d\u5236\u5230\u5176\u4ed6\u4f4d\u7f6e \u4e3a\u4e86\u590d\u5236\u4e0a\u4f20\u5230 input file \u4e2d\u7684\u6587\u4ef6\u5230\u5176\u4ed6\u4f4d\u7f6e\uff0c\u9700\u8981\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u4f7f\u7528 form \u8868\u5355\u4e0a\u4f20\u6587\u4ef6\uff1a &lt;form action=&#8217;xx.php&#8217; method=&#8217;post&#8217; enctype=&#8217;multipart\/form-data&#8217;&gt; &lt;input type=&#8217;file&#8217; name=&#8217;file&#8217;&gt; &lt;input type=&#8217;button&#8217; name=&#8217;btn&#8217; value=&#8217;upload&#8217;&gt; &lt;\/form&gt; \u63a5\u6536\u4e0a\u4f20\u6587\u4ef6\uff1a\u5728 php \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7 $_files \u6570\u7ec4\u83b7\u53d6\u4e0a\u4f20\u6587\u4ef6\u7684\u4fe1\u606f\uff1a if (isset($_files[&#8216;file&#8217;])) { $file = $_files[&#8216;file&#8217;]; } \u79fb\u52a8\u4e0a\u4f20\u6587\u4ef6\uff1a\u4f7f\u7528 move_uploaded_file \u51fd\u6570\u5c06\u4e0a\u4f20\u6587\u4ef6\u79fb\u52a8\u5230\u6307\u5b9a\u4f4d\u7f6e\uff1a $targetPath = &#8216;.\/1.jpg&#8217;; move_uploaded_file($file[&#8216;tmp_name&#8217;], $targetPath); \u6b64\u64cd\u4f5c\u5c06\u4ece\u4e34\u65f6\u5b58\u50a8\u4f4d\u7f6e\u79fb\u52a8\u6587\u4ef6\u5230\u6307\u5b9a\u7684 $targetpath \u8def\u5f84\u3002\u8bf7\u786e\u4fdd\u8be5\u8def\u5f84\u5177\u6709\u9002\u5f53\u7684\u5199\u5165\u6743\u9650\u3002 \u672c\u7bc7\u5173\u4e8e\u300a\u4e0a\u4f20\u7684\u6587\u4ef6\u5982\u4f55\u79fb\u52a8\u5230\u670d\u52a1\u5668\u6307\u5b9a\u4f4d\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","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-49378","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49378","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=49378"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49378\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}