{"id":28427,"date":"2024-11-24T10:56:23","date_gmt":"2024-11-24T02:56:23","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28427\/"},"modified":"2024-11-24T10:56:23","modified_gmt":"2024-11-24T02:56:23","slug":"php-%e4%b8%ad%e7%9a%84%e7%ae%80%e5%8d%95%e6%96%87%e4%bb%b6%e4%b8%8a%e4%bc%a0","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28427\/","title":{"rendered":"php \u4e2d\u7684\u7b80\u5355\u6587\u4ef6\u4e0a\u4f20"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173201460818627.jpg\" class=\"aligncenter\" title=\"php \u4e2d\u7684\u7b80\u5355\u6587\u4ef6\u4e0a\u4f20\u63d2\u56fe\" alt=\"php \u4e2d\u7684\u7b80\u5355\u6587\u4ef6\u4e0a\u4f20\u63d2\u56fe\" \/><\/p>\n<h3> html \u8868\u5355 <\/h3>\n<p>\/index.html :<\/p>\n<pre>&lt;!doctype html&gt;\n&lt;html lang=\"en\"&gt;\n  &lt;head&gt;\n    &lt;meta charset=\"utf-8\" \/&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/&gt;\n    &lt;title&gt;document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;form method=\"post\" action=\"upload.php\" enctype=\"multipart\/form-data\"&gt;\n      &lt;label for=\"file-label\"&gt;file : &lt;\/label&gt;\n      &lt;input type=\"file\" name=\"myfile\" id=\"myfile\" \/&gt;\n      &lt;input type=\"submit\" name=\"submit\" id=\"submit\" value=\"submit\" \/&gt;\n    &lt;\/form&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3> \u6587\u4ef6\u4e0a\u4f20\u5904\u7406\u7a0b\u5e8f <\/h3>\n<p>\/upload.php :<\/p>\n<pre>&lt;?php\n$tempFile = $_FILES['myfile']['tmp_name'];\n$fileName = $_FILES['myfile']['name'];\n\n$fileDestination = __DIR__.\"\/uploads\/\".$fileName;\n\ncopy($tempFile, $fileDestination);\n\nunlink($tempFile);\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><br \/> \u5fc5\u987b\u4e8b\u5148\u521b\u5efa \/uploads \u6587\u4ef6\u5939\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fphp \u4e2d\u7684\u7b80\u5355\u6587\u4ef6\u4e0a\u4f20\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>html \u8868\u5355 \/index.html : &lt;!doctype html&gt; &lt;html lang=&#8221;en&#8221;&gt; &lt;head&gt; &lt;meta charset=&#8221;utf-8&#8243; \/&gt; &lt;meta name=&#8221;viewport&#8221; content=&#8221;width=device-width, initial-scale=1.0&#8243; \/&gt; &lt;title&gt;document&lt;\/title&gt; &lt;\/head&gt; &lt;body&gt; &lt;form method=&#8221;post&#8221; action=&#8221;upload.php&#8221; enctype=&#8221;multipart\/form-data&#8221;&gt; &lt;label for=&#8221;file-label&#8221;&gt;file : &lt;\/label&gt; &lt;input type=&#8221;file&#8221; name=&#8221;myfile&#8221; id=&#8221;myfile&#8221; \/&gt; &lt;input type=&#8221;submit&#8221; name=&#8221;submit&#8221; id=&#8221;submit&#8221; value=&#8221;submit&#8221; \/&gt; &lt;\/form&gt; &lt;\/body&gt; &lt;\/html&gt; \u767b\u5f55\u540e\u590d\u5236 \u6587\u4ef6\u4e0a\u4f20\u5904\u7406\u7a0b\u5e8f \/upload.php : &lt;?php $tempFile = $_FILES[&#8216;myfile&#8217;][&#8216;tmp_name&#8217;]; $fileName = $_FILES[&#8216;myfile&#8217;][&#8216;name&#8217;]; $fileDestination = [&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-28427","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28427","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=28427"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28427\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}