{"id":3928,"date":"2011-10-25T11:09:20","date_gmt":"2011-10-25T03:09:20","guid":{"rendered":"http:\/\/wp.chunhsin.idv.tw\/?p=3928"},"modified":"2011-10-25T11:09:20","modified_gmt":"2011-10-25T03:09:20","slug":"%e6%aa%a2%e6%9f%a5_post%e5%85%a7%e5%ae%b9%e6%98%af%e5%90%a6%e8%b6%85%e9%81%8e%e9%99%90%e5%88%b6","status":"publish","type":"post","link":"https:\/\/wp.chunhsin.idv.tw\/?p=3928","title":{"rendered":"\u6aa2\u67e5$_POST\u5167\u5bb9\u662f\u5426\u8d85\u904e\u9650\u5236"},"content":{"rendered":"<p>$_POST\u7684\u5927\u5c0f\u9650\u5236\u8a2d\u5b9a\u5728php.ini\u7684post_max_size\u9019\u500b\u6307\u4ee4\u88e1\uff0c\u6211\u5011\u53ef\u4ee5\u76f4\u63a5\u6307\u5b9a\u4ee5byte\u70ba\u55ae\u4f4d\u7684\u6578\u5b57\uff0c\u4f8b\u59821024\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u52a0\u4e0a\u55ae\u4f4d\uff0c\u4f8b\u59821K\uff0c\u4f461\u548cK\u4e4b\u9593\u4e0d\u80fd\u6709\u4efb\u4f55\u7a7a\u683c\uff0c\u5426\u5247\u5c31\u6703\u51fa\u73feInternal Server Error\u7684\u8a0a\u606f\u3002\u53e6\u5916\uff0c\u6839\u64daphp\u5b98\u7db2\u7684\u8a0a\u606f\uff0c\u4e0a\u8ff0\u55ae\u4f4d\u6700\u5927\u53ef\u4f7f\u7528\u5230g\u3002<\/p>\n<p>\u96d6\u7136\u6709\u6307\u5b9apost\u7684\u5927\u5c0f\u9650\u5236\uff0c\u4f46\u7576\u8d85\u904e\u9650\u5236\u7684\u6642\u5019\uff0c\u53ef\u80fd\u4e0d\u4e00\u5b9a\u80fd\u5920\u770b\u5230\u932f\u8aa4\u8a0a\u606f\uff0c\u9019\u53d6\u6c7a\u65bcphp.ini\u88e1\u7684display_startup_errors\u6307\u4ee4\u662f\u5426\u8a2d\u70baon\uff0c\u7576\u6b64\u6307\u4ee4\u8a2d\u70baoff(\u9810\u8a2d)\u6642\uff0c\u6211\u5011\u662f\u770b\u4e0d\u5230\u932f\u8aa4\u8a0a\u606f\u7684\u3002<!--more--><\/p>\n<p>\u9664\u4e86\u770b\u4e0d\u5230\u932f\u8aa4\u8a0a\u606f\u4e4b\u5916\uff0c\u5b83\u9084\u6703\u9023\u5e36\u5f71\u97ff\u5230$_FILES\u9663\u5217\u7684\u5224\u5225\u3002\u539f\u4f86\u662f\u7576\u8868\u55ae\u5927\u5c0f\u8d85\u904epost_max_size\u7684\u8a2d\u5b9a\u5f8c\uff0c$_POST\u5c31\u6703\u76f4\u63a5\u300c\u7206\u70b8\u300d\uff0c\u5c31\u597d\u50cf\u6c23\u7403\u704c\u592a\u591a\u6c23\u76f4\u63a5\u7206\u70b8\u4e00\u6a23\uff0c\u7d50\u679c\u5e7e\u4e4e\u4ec0\u9ebc\u90fd\u6c92\u6709\u5269\u4e0b\uff0c\u53ea\u5269\u4e0b$_SERVER[&#8216;CONTENT_LENGTH&#8217;]\u9084\u6709\u8a18\u9304\u539f\u59cb\u7684\u8868\u55ae\u5927\u5c0f\uff0c$_FILES\u4e5f\u4e0d\u6703\u7522\u751f\uff0c\u9023\u7a7a\u9663\u5217\u90fd\u4e0d\u662f\uff0c\u9019\u6a23\u4e5f\u5c31\u6c92\u6709\u8fa6\u6cd5\u5229\u7528$_FILES[filename][&#8216;error&#8217;]\u4f86\u5224\u65b7\u4e0a\u50b3\u6a94\u6848\u7684\u932f\u8aa4\u3002<\/p>\n<p>\u56e0\u70ba\u8d85\u904e\u9650\u5236\u6642$_POST\u6703\u8b8a\u6210\u7a7a\u9663\u5217\uff0c\u6211\u5011\u4e5f\u6c92\u6709\u8fa6\u6cd5\u4f7f\u7528if($_POST)\u4f86\u6b63\u78ba\u5224\u5225\u7576\u6b21\u662f\u5426\u70bapost\u904e\u4f86\u7684\u8cc7\u6599\uff0c\u800c\u4e14\u5728display_startup_errors\u70baoff\u7684\u60c5\u6cc1\u4e0b\u9084\u4e0d\u6703\u986f\u793a\u4efb\u4f55\u932f\u8aa4\u8a0a\u606f\uff0c\u9019\u6703\u8b93\u4eba\u5c0f\u50b7\u8166\u7b4b\u4e00\u756a\u3002<\/p>\n<p>\u6240\u5e78post\u904e\u4f86\u7684\u72c0\u6cc1\u4e0b\uff0c$_SERVER\u6709\u4e00\u4e9b\u8a0a\u606f\u9084\u883b\u6709\u7528\u7684\uff0c\u4f8b\u5982$_SERVER[&#8216;REQUEST_METHOD&#8217;]\u4ee3\u8868\u662f\u4f7f\u7528POST\u6216\u662fGET\uff0c$_SERVER[&#8216;CONTENT_LENGTH&#8217;]\u5247\u662f\u4ee3\u8868\u539f\u59cb\u4e0a\u50b3\u8868\u55ae\u7684\u5927\u5c0f\uff0c\u6211\u5011\u53ef\u4ee5\u62ff\u5b83\u4f86\u548cupload_max_filesize\u9019\u500b\u6307\u4ee4\u8a2d\u5b9a\u7684\u503c\u4f86\u6bd4\u8f03\u3002\u5982\u679c$_SERVER[&#8216;REQUEST_METHOD&#8217;]\u662fPOST\uff0c\u800c\u4e14upload_max_filesize\u5927\u65bc$_SERVER[&#8216;CONTENT_LENGTH&#8217;]\uff0c\u4ee3\u8868\u6b64\u6b21\u8868\u55ae\u662f\u4ee5POST\u7684\u65b9\u5f0f\u4e0a\u50b3\uff0c\u800c\u4e14\u5927\u5c0f\u5927\u9650\u5236\u4e4b\u5167\uff0c\u53ef\u4ee5\u7e7c\u7e8c\u505a\u8655\u7406\uff0c\u53cd\u4e4b\u5c31\u5fc5\u9808\u63d0\u4f9b\u932f\u8aa4\u8a0a\u606f\u4f86\u63d0\u793a\u4f7f\u7528\u8005\u3002<\/p>\n<p>\u6240\u4ee5\u6211\u5c31\u5beb\u4e86\u4e00\u500b\u51fd\u6578\u4f86\u505a\u9019\u6a23\u5b50\u7684\u5224\u5225\uff1a<\/p>\n<blockquote><p><strong>function<\/strong> is_post(){<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">$val<\/span> = trim(ini_get(<span style=\"color: #339966;\">&#8220;upload_max_filesize&#8221;<\/span>));<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">$last<\/span> = strtolower(<span style=\"color: #0000ff;\">$val<\/span>[strlen(<span style=\"color: #0000ff;\">$val<\/span>)-1]);<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #339966;\">\/\/\u9700\u5c0dupload_max_filesize\u6307\u4ee4\u7684\u503c\u505a\u4e00\u4e9b\u8655\u7406\uff0c\u8f49\u63db\u70ba\u4ee5byte\u70ba\u55ae\u4f4d<\/span><\/p>\n<p style=\"padding-left: 30px;\"><strong>switch<\/strong>(<span style=\"color: #0000ff;\">$last<\/span>) {<\/p>\n<p style=\"padding-left: 60px;\"><span style=\"color: #339966;\">\/\/ The &#8216;G&#8217; modifier is available since PHP 5.1.0<\/span><\/p>\n<p style=\"padding-left: 60px;\"><strong>case<\/strong> <span style=\"color: #339966;\">&#8216;g&#8217;<\/span>:<\/p>\n<p style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">$val<\/span> *= 1024;<\/p>\n<p style=\"padding-left: 60px;\"><strong>case<\/strong> <span style=\"color: #339966;\">&#8216;m&#8217;<\/span>:<\/p>\n<p style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">$val<\/span> *= 1024;<\/p>\n<p style=\"padding-left: 60px;\"><strong>case<\/strong> <span style=\"color: #339966;\">&#8216;k&#8217;<\/span>:<\/p>\n<p style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">$val<\/span> *= 1024;<\/p>\n<p style=\"padding-left: 30px;\">}<\/p>\n<p style=\"padding-left: 30px;\"><strong>if<\/strong>(<span style=\"color: #0000ff;\">$_SERVER<\/span>[<span style=\"color: #339966;\">&#8216;REQUEST_METHOD&#8217;<\/span>]==<span style=\"color: #339966;\">&#8216;POST&#8217;<\/span>){<\/p>\n<p style=\"padding-left: 60px;\"><strong>if<\/strong>(<span style=\"color: #0000ff;\">$val<\/span> &gt;= <span style=\"color: #0000ff;\">$_SERVER<\/span>[<span style=\"color: #339966;\">&#8216;CONTENT_LENGTH&#8217;<\/span>]){<\/p>\n<p style=\"padding-left: 90px;\"><strong>return true<\/strong>;<\/p>\n<p style=\"padding-left: 60px;\">}<strong>else<\/strong>{<\/p>\n<p style=\"padding-left: 90px;\">trigger_error(<span style=\"color: #339966;\">&#8220;\u4e0a\u50b3\u8868\u55ae\u5927\u5c0f\u8d85\u904e\u9650\u5236!&#8221;<\/span>,E_USER_WARNING);<\/p>\n<p style=\"padding-left: 60px;\">}<\/p>\n<p style=\"padding-left: 30px;\">}<\/p>\n<p>}<\/p><\/blockquote>\n<p>\u6700\u5f8c\u8aaa\u660e\u4e00\u500b\u554f\u984c\uff0c\u5728\u5176\u4ed6\u7db2\u7ad9\u6709\u770b\u5230\u4e00\u4e9b\u8aaa\u660e\uff0c\u6307\u51famemory_limit\u9019\u500b\u6307\u4ee4\u4e5f\u548cpost_max_size\u76f8\u95dc\uff0c\u4e0d\u904e\u7d93\u6e2c \u8a66\uff0cmemory_limit\u548cpost_max_size\u5927\u5c0f\u6c92\u6709\u95dc\u4fc2\uff0c\u6b64\u6b21\u6e2c\u8a66\u74b0\u5883\u5728Apache Web Server Version 2.2.8\u3001PHP Script Language Version 5.2.6\u3001Windows Xp\u3002<\/p>\n<p>\u53c3\u8003\u4f86\u6e90\uff1a<\/p>\n<p>1\uff1a<a title=\"ini_get\" href=\"http:\/\/tw.php.net\/manual\/en\/function.ini-get.php\" target=\"_blank\">http:\/\/tw.php.net\/manual\/en\/function.ini-get.php<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>$_POST\u7684\u5927\u5c0f\u9650\u5236\u8a2d\u5b9a\u5728php.ini\u7684post_max_size\u9019\u500b\u6307\u4ee4\u88e1\uff0c\u6211\u5011\u53ef\u4ee5\u76f4\u63a5\u6307\u5b9a\u4ee5byte\u70ba &hellip; <a href=\"https:\/\/wp.chunhsin.idv.tw\/?p=3928\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008\u6aa2\u67e5$_POST\u5167\u5bb9\u662f\u5426\u8d85\u904e\u9650\u5236\u3009<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,12],"tags":[173],"class_list":["post-3928","post","type-post","status-publish","format-standard","hentry","category-php","category-freetalking","tag-173"],"_links":{"self":[{"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/3928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3928"}],"version-history":[{"count":11,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/3928\/revisions"}],"predecessor-version":[{"id":3945,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/3928\/revisions\/3945"}],"wp:attachment":[{"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}