{"id":26961,"date":"2024-11-24T16:59:01","date_gmt":"2024-11-24T08:59:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26961\/"},"modified":"2024-11-24T16:59:01","modified_gmt":"2024-11-24T08:59:01","slug":"php%e5%a6%82%e4%bd%95%e8%8e%b7%e5%8f%96%e4%b8%8a%e4%bc%a0%e9%a1%b5%e9%9d%a2%e4%b8%addiv%e7%9a%84%e5%86%85%e5%ae%b9%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26961\/","title":{"rendered":"PHP\u5982\u4f55\u83b7\u53d6\u4e0a\u4f20\u9875\u9762\u4e2ddiv\u7684\u5185\u5bb9\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173113654346269.jpg\" class=\"aligncenter\" title=\"PHP\u5982\u4f55\u83b7\u53d6\u4e0a\u4f20\u9875\u9762\u4e2ddiv\u7684\u5185\u5bb9\uff1f\u63d2\u56fe\" alt=\"PHP\u5982\u4f55\u83b7\u53d6\u4e0a\u4f20\u9875\u9762\u4e2ddiv\u7684\u5185\u5bb9\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5728php\u4e2d\u83b7\u53d6div\u4e2d\u663e\u793a\u7684\u5185\u5bb9<\/strong><\/p>\n<p>\u8981\u5728\u4e0a\u4f20\u9875\u9762\u63d0\u4ea4\u540e\u4ece\u53e6\u4e00\u4e2aPHP\u6587\u4ef6\u4e2d\u83b7\u53d6div\u4e2d\u7684\u5185\u5bb9\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<p><strong>\u4f7f\u7528\u9690\u85cf\u8868\u5355\u8f93\u5165<\/strong><\/p>\n<ol>\n<li>\u5728\u4e0a\u4f20\u9875\u9762\u4e2d\uff0c\u5c06div\u7684\u5185\u5bb9\u8d4b\u7ed9\u4e00\u4e2a\u9690\u85cf\u8868\u5355\u8f93\u5165\uff1a<\/li>\n<\/ol>\n<pre>uploader.on('uploadSuccess', function(file, response) {\n  $('#imgs_url').val(response.imgurl);\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u5728\u8868\u5355\u4e2d\u6dfb\u52a0\u9690\u85cf\u8f93\u5165\uff1a<\/li>\n<\/ol>\n<pre>&lt;form method=\"post\" action=\"upload.php\"&gt;\n &lt;input type=\"hidden\" id=\"imgs_url\" name=\"imgs_url\" value=\"\"&gt;\n&lt;\/form&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u5728\u4e0a\u4f20PHP\u9875\u9762\u4e2d\uff0c\u901a\u8fc7 $_POST[&#8216;imgs_url&#8217;] \u83b7\u53d6\u9690\u85cf\u8f93\u5165\u4e2d\u7684\u5185\u5bb9\u3002<\/li>\n<\/ol>\n<p><strong>\u76f4\u63a5\u4eceJS\u83b7\u53d6<\/strong><\/p>\n<p>\u5982\u679c\u9700\u8981\u5728\u4e0d\u63d0\u4ea4\u8868\u5355\u7684\u60c5\u51b5\u4e0b\u76f4\u63a5\u4eceJS\u4e2d\u83b7\u53d6div\u4e2d\u7684\u5185\u5bb9\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>const imgUrl = $('#imgs_url').text();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fPHP\u5982\u4f55\u83b7\u53d6\u4e0a\u4f20\u9875\u9762\u4e2ddiv\u7684\u5185\u5bb9\uff1f\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>\u5728php\u4e2d\u83b7\u53d6div\u4e2d\u663e\u793a\u7684\u5185\u5bb9 \u8981\u5728\u4e0a\u4f20\u9875\u9762\u63d0\u4ea4\u540e\u4ece\u53e6\u4e00\u4e2aPHP\u6587\u4ef6\u4e2d\u83b7\u53d6div\u4e2d\u7684\u5185\u5bb9\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u4f7f\u7528\u9690\u85cf\u8868\u5355\u8f93\u5165 \u5728\u4e0a\u4f20\u9875\u9762\u4e2d\uff0c\u5c06div\u7684\u5185\u5bb9\u8d4b\u7ed9\u4e00\u4e2a\u9690\u85cf\u8868\u5355\u8f93\u5165\uff1a uploader.on(&#8216;uploadSuccess&#8217;, function(file, response) { $(&#8216;#imgs_url&#8217;).val(response.imgurl); }); \u767b\u5f55\u540e\u590d\u5236 \u5728\u8868\u5355\u4e2d\u6dfb\u52a0\u9690\u85cf\u8f93\u5165\uff1a &lt;form method=&#8221;post&#8221; action=&#8221;upload.php&#8221;&gt; &lt;input type=&#8221;hidden&#8221; id=&#8221;imgs_url&#8221; name=&#8221;imgs_url&#8221; value=&#8221;&#8221;&gt; &lt;\/form&gt; \u767b\u5f55\u540e\u590d\u5236 \u5728\u4e0a\u4f20PHP\u9875\u9762\u4e2d\uff0c\u901a\u8fc7 $_POST[&#8216;imgs_url&#8217;] \u83b7\u53d6\u9690\u85cf\u8f93\u5165\u4e2d\u7684\u5185\u5bb9\u3002 \u76f4\u63a5\u4eceJS\u83b7\u53d6 \u5982\u679c\u9700\u8981\u5728\u4e0d\u63d0\u4ea4\u8868\u5355\u7684\u60c5\u51b5\u4e0b\u76f4\u63a5\u4eceJS\u4e2d\u83b7\u53d6div\u4e2d\u7684\u5185\u5bb9\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b const imgUrl = $(&#8216;#imgs_url&#8217;).text(); \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u5c31\u662fPHP\u5982\u4f55\u83b7\u53d6\u4e0a\u4f20\u9875\u9762\u4e2ddiv\u7684\u5185\u5bb9\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\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-26961","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26961","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=26961"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26961\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}