{"id":487,"date":"2014-07-08T15:07:34","date_gmt":"2014-07-08T15:07:34","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=487"},"modified":"2014-07-08T15:07:34","modified_gmt":"2014-07-08T15:07:34","slug":"%e4%b8%ba%e4%bb%80%e4%b9%88%e6%96%87%e4%bb%b6%e4%b8%8a%e4%bc%a0%e8%a1%a8%e5%8d%95%e6%98%af%e4%b8%bb%e8%a6%81%e7%9a%84%e5%ae%89%e5%85%a8%e5%a8%81%e8%83%81","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/487.html","title":{"rendered":"\u4e3a\u4ec0\u4e48\u6587\u4ef6\u4e0a\u4f20\u8868\u5355\u662f\u4e3b\u8981\u7684\u5b89\u5168\u5a01\u80c1"},"content":{"rendered":"<p><span style=\"color: #000000;\">\u8ba9<\/span><span style=\"color: #000000;\">\u7528\u6237<\/span><span style=\"color: #000000;\">\u5c06\u6587\u4ef6\u4e0a\u4f20\u5230<\/span><span style=\"color: #000000;\">\u60a8\u7684\u7f51\u7ad9<\/span><span style=\"color: #000000;\">\uff0c<\/span><span style=\"color: #000000;\">\u5c31\u50cf\u662f\u7ed9\u5371\u53ca\u60a8\u7684\u670d\u52a1\u5668\u7684\u6076\u610f\u7528\u6237<\/span><span style=\"color: #000000;\">\u6253\u5f00<\/span><span style=\"color: #000000;\">\u4e86\u53e6\u4e00\u6247\u95e8<\/span><span style=\"color: #000000;\">\u3002<\/span><span style=\"color: #000000;\">\u5373\u4fbf\u5982\u6b64\uff0c<\/span><span style=\"color: #000000;\">\u5728\u4eca\u5929\u7684\u73b0\u4ee3<\/span><span style=\"color: #000000;\">\u4e92\u8054\u7f51<\/span><span style=\"color: #000000;\">\u7684Web\u5e94\u7528\u7a0b\u5e8f<\/span><span style=\"color: #000000;\">\uff0c<\/span><span style=\"color: #000000;\">\u5b83<\/span><span style=\"color: #000000;\">\u662f\u4e00\u79cd\u5e38\u89c1\u7684<\/span><span style=\"color: #000000;\">\u8981\u6c42<\/span><span style=\"color: #000000;\">\uff0c<\/span><span style=\"color: #000000;\">\u56e0\u4e3a<\/span><span style=\"color: #000000;\">\u5b83\u6709\u52a9\u4e8e<\/span><span style=\"color: #000000;\">\u63d0\u9ad8<\/span><span style=\"color: #000000;\">\u60a8\u7684\u4e1a\u52a1<\/span><span style=\"color: #000000;\">\u6548\u7387<\/span><span style=\"color: #000000;\">\u3002<\/span><span style=\"color: #000000;\">\u5728<\/span><span style=\"color: #000000;\">Facebook\u548cTwitter<\/span><span style=\"color: #000000;\">\u7b49<\/span><span style=\"color: #000000;\">\u793e\u4ea4\u7f51\u7edc<\/span><span style=\"color: #000000;\">\u7684Web\u5e94\u7528\u7a0b\u5e8f<\/span><span style=\"color: #000000;\">\uff0c<\/span><span style=\"color: #000000;\">\u5141\u8bb8<\/span><span style=\"color: #000000;\">\u6587\u4ef6\u4e0a\u4f20<\/span><span style=\"color: #000000;\">\u3002<\/span><span style=\"color: #000000;\">\u4e5f\u8ba9\u4ed6\u4eec<\/span><span style=\"color: #000000;\">\u5728<\/span><span style=\"color: #000000;\">\u535a\u5ba2\uff0c\u8bba\u575b\uff0c<\/span><span style=\"color: #000000;\">\u7535\u5b50\u94f6\u884c<\/span><span style=\"color: #000000;\">\u7f51\u7ad9<\/span><span style=\"color: #000000;\">\uff0c<\/span><span style=\"color: #000000;\">YouTube\u548c<\/span><span style=\"color: #000000;\">\u4f01\u4e1a<\/span><span style=\"color: #000000;\">\u652f\u6301\u95e8\u6237<\/span><span style=\"color: #000000;\">\uff0c\u7ed9<\/span><span style=\"color: #000000;\">\u673a\u4f1a<\/span><span style=\"color: #000000;\">\u7ed9\u6700\u7ec8\u7528\u6237<\/span><span style=\"color: #000000;\">\u4e0e<\/span><span style=\"color: #000000;\">\u4f01\u4e1a<\/span><span style=\"color: #000000;\">\u5458\u5de5<\/span><span style=\"color: #000000;\">\u6709\u6548\u5730\u5171\u4eab<\/span><span style=\"color: #000000;\">\u6587\u4ef6<\/span><span style=\"color: #000000;\">\u3002<\/span><span style=\"color: #000000;\">\u5141\u8bb8<\/span><span style=\"color: #000000;\">\u7528\u6237<\/span><span style=\"color: #000000;\">\u4e0a\u4f20\u56fe\u7247\uff0c<\/span><span style=\"color: #000000;\">\u89c6\u9891<\/span><span style=\"color: #000000;\">\uff0c\u5934\u50cf\u548c<\/span><span style=\"color: #000000;\">\u8bb8\u591a<\/span><span style=\"color: #000000;\">\u5176\u4ed6\u7c7b\u578b\u7684\u6587\u4ef6<\/span><span style=\"color: #000000;\">\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u5411\u7ec8\u7aef\u7528\u6237<\/span><span style=\"color: #000000;\">\u63d0\u4f9b<\/span><span style=\"color: #000000;\">\u7684\u529f\u80fd\u8d8a\u591a<\/span><span style=\"color: #000000;\">\uff0c<\/span><span style=\"color: #000000;\">Web<\/span><span style=\"color: #000000;\">\u5e94\u7528\u53d7\u5230\u653b\u51fb<\/span><span style=\"color: #000000;\">\u7684\u98ce\u9669<\/span><span style=\"color: #000000;\">\u548c<\/span><span style=\"color: #000000;\">\u673a\u4f1a\u5c31\u8d8a\u5927<\/span><span style=\"color: #000000;\">\uff0c\u8fd9\u79cd<\/span><span style=\"color: #000000;\">\u529f\u80fd<\/span><span style=\"color: #000000;\">\u4f1a<\/span><span style=\"color: #000000;\">\u88ab<\/span><span style=\"color: #000000;\">\u6076\u610f\u7528\u6237\u5229\u7528<\/span><span style=\"color: #000000;\">\uff0c<\/span><span style=\"color: #000000;\">\u83b7\u5f97<\/span><span style=\"color: #000000;\">\u5230\u4e00\u4e2a\u7279\u5b9a<\/span><span style=\"color: #000000;\">\u7f51\u7ad9<\/span><span style=\"color: #000000;\">\u7684\u6743\u9650\uff0c<\/span><span style=\"color: #000000;\">\u6216<\/span><span style=\"color: #000000;\">\u5371\u53ca<\/span><span style=\"color: #000000;\">\u670d\u52a1\u5668<\/span><span style=\"color: #000000;\">\u7684\u53ef\u80fd\u6027\u662f\u975e\u5e38\u9ad8\u7684<\/span><span style=\"color: #000000;\">\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u5f53\u5728\u6d4b\u8bd5\u51e0\u4e2a<\/span><span style=\"color: #000000;\">Web\u5e94\u7528\u7a0b\u5e8f<\/span><span style=\"color: #000000;\">\u65f6<\/span><span style=\"color: #000000;\">\uff0c\u6211\u4eec<\/span><span style=\"color: #000000;\">\u6ce8\u610f\u5230<\/span><span style=\"color: #000000;\">\uff0c\u76f8\u5f53\u591a<\/span><span style=\"color: #000000;\">\u7684\u77e5\u540d<\/span><span style=\"color: #000000;\">Web\u5e94\u7528\u7a0b\u5e8f<\/span><span style=\"color: #000000;\">\uff0c\u4e0d\u5177\u5907<\/span><span style=\"color: #000000;\">\u5b89\u5168<\/span><span style=\"color: #000000;\">\u7684<\/span><span style=\"color: #000000;\">\u6587\u4ef6\u4e0a\u4f20<\/span><span style=\"color: #000000;\">\u5f62\u5f0f<\/span><span style=\"color: #000000;\">\u3002<\/span><span style=\"color: #000000;\">\u8fd9\u4e9b\u6f0f\u6d1e<\/span><span style=\"color: #000000;\">\u5f88\u5bb9\u6613\u88ab<\/span><span style=\"color: #000000;\">\u5229\u7528<\/span><span style=\"color: #000000;\">\uff0c\u6211\u4eec\u53ef\u4ee5<\/span><span style=\"color: #000000;\">\u8bbf\u95ee<\/span><span style=\"color: #000000;\">\u8fd9\u4e9bWeb\u5e94\u7528\u7a0b\u5e8f<\/span><span style=\"color: #000000;\">\u7684\u670d\u52a1\u5668\u7684<\/span><span style=\"color: #000000;\">\u6587\u4ef6\u7cfb\u7edf<\/span><span style=\"color: #000000;\">\u3002<\/span><span style=\"color: #000000;\">\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d<\/span><span style=\"color: #000000;\">\uff0c<\/span><span style=\"color: #000000;\">\u6211\u4eec\u4e3a\u60a8\u4ecb\u7ecd<\/span><span style=\"color: #000000;\">8\u79cd\u5e38\u89c1<\/span><span style=\"color: #000000;\">\u7684<\/span><span style=\"color: #000000;\">\u65b9\u5f0f<\/span><span style=\"color: #000000;\">\uff0c<\/span><span style=\"color: #000000;\">\u6211\u4eec\u9047\u5230\u8fc7<\/span><span style=\"color: #000000;\">\u7684\u5b89\u5168<\/span><span style=\"color: #000000;\">\u6587\u4ef6\u4e0a\u4f20<\/span><span style=\"color: #000000;\">\u8868\u5355<\/span><span style=\"color: #000000;\">\u3002<\/span><span style=\"color: #000000;\">\u540c\u65f6\uff0c\u8fd8\u5c06\u5c55\u793a<\/span><span style=\"color: #000000;\">\u4e00\u4e2a<\/span><span style=\"color: #000000;\">\u6076\u610f<\/span><span style=\"color: #000000;\">\u7684<\/span><span style=\"color: #000000;\">\u7528\u6237<\/span><span style=\"color: #000000;\">\uff0c<\/span><span style=\"color: #000000;\">\u53ef\u4ee5\u8f7b\u677e\u5730<\/span><span style=\"color: #000000;\">\u7ed5\u8fc7<\/span><span style=\"color: #000000;\">\u8fd9\u4e9b<\/span><span style=\"color: #000000;\">\u5b89\u5168\u63aa\u65bd<\/span><span style=\"color: #000000;\">\u3002<\/span><\/p>\n<h2 id=\"content_h2_3_5\" style=\"color: #000000;\">\u60c5\u5f62\u4e00: \u7b80\u5355\u7684\u3001\u6ca1\u6709\u9a8c\u8bc1\u7684\u6587\u4ef6\u4e0a\u4f20\u8868\u5355<\/h2>\n<p style=\"color: #000000;\">\u4e00\u4e2a\u7b80\u5355\u7684\u6587\u4ef6\u4e0a\u4f20\u8868\u5355\u5e38\u5e38\u5305\u542b\u4e00\u4e9bHTML\u8868\u5355\u548cPHP\u811a\u672c\u3002HTML\u8868\u5355\u4ee5\u9875\u9762\u7684\u5f62\u5f0f\u5c55\u73b0\u7ed9\u7528\u6237\uff0c\u800cPHP\u811a\u672c\u5219\u8d1f\u8d23\u5904\u7406\u6587\u4ef6\u4e0a\u4f20\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u5305\u542bHTML\u8868\u5355\u548cPHP\u811a\u672c\u7684\u7b80\u5355\u4f8b\u5b50\uff1a<\/p>\n<p style=\"color: #000000;\"><strong>HTML \u8868\u5355:<\/strong><\/p>\n<pre class=\"lang:default decode:true\">&lt;form enctype=\"multipart\/form-data\" action=\"uploader.php\" method=\"POST\"&gt;\n&lt;input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"100000\" \/&gt;\nChoose a file to upload: &lt;input name=\"uploadedfile\" type=\"file\" \/&gt;&lt;br \/&gt;\n&lt;input type=\"submit\" value=\"Upload File\" \/&gt;\n&lt;\/form&gt;<\/pre>\n<p><strong style=\"color: #000000;\">PHP \u811a\u672c:<\/strong><\/p>\n<pre class=\"lang:default decode:true\">&lt;?php\n    $target_path  =  \"uploads\/\";\n    $target_path  =  $target_path  .  basename($_FILES['uploadedfile']['name']);\n    if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {\n    echo \"\u6587\u4ef6 \" . basename($_FILES['uploadedfile']['name']) . \" \u4e0a\u4f20\u6210\u529f\uff01\";\n    } else {\n    echo \"\u6587\u4ef6\u4e0a\u4f20\u9047\u5230\u9519\u8bef\uff0c\u8bf7\u91cd\u8bd5\uff01\";\n    }\n?&gt;<\/pre>\n<p><span style=\"color: #000000;\">\u5f53PHP\u63a5\u6536\u5230\u4e00\u4e2a\u00a0<\/span><strong style=\"color: #000000;\">multipart\/form-data<\/strong><span style=\"color: #000000;\">\u7c7b\u578b\u7684\u00a0<\/span><strong style=\"color: #000000;\">POST<\/strong><span style=\"color: #000000;\">\u8bf7\u6c42\u65f6\uff0cPHP\u4f1a\u5728\u4e34\u65f6\u6587\u4ef6\u5939\uff08\u4f8b\u5982\uff1a\/var\/tmp\/php6yXOVs\uff09\u521b\u5efa\u4e00\u4e2a\u540d\u5b57\u968f\u673a\u751f\u6210\u7684\u4e34\u65f6\u6587\u4ef6\u3002\u540c\u65f6\uff0cPHP\u4e5f\u4f1a\u628a\u4e0a\u4f20\u6587\u4ef6\u7684\u4fe1\u606f\u4fdd\u5b58\u5230\u5168\u5c40\u6570\u7ec4\u00a0<\/span><strong style=\"color: #000000;\">$_FILES<\/strong><span style=\"color: #000000;\">\u5f53\u4e2d\uff0c\u683c\u5f0f\u5982\u4e0b\u00a0<\/span><span style=\"color: #000000;\">\uff1a<\/span><\/p>\n<ul style=\"color: #000000;\">\n<li>$_FILES[\u2018uploadedfile\u2019][\u2018name\u2019]: \u4e0a\u4f20\u6587\u4ef6\u7684\u539f\u6587\u4ef6\u540d<\/li>\n<li>$_FILES[\u2018uploadedfile\u2019][\u2018type\u2019]: \u4e0a\u4f20\u6587\u4ef6\u7684MIME TYPE<\/li>\n<li>$_FILES[\u2018uploadedfile\u2019][\u2018size\u2019]: \u4e0a\u4f20\u6587\u4ef6\u7684\u5927\u5c0f\uff08\u5355\u4f4d\u4e3abyte\uff09<\/li>\n<li>$_FILES[\u2018uploadedfile\u2019][\u2018tmp_name\u2019]: \u4e0a\u4f20\u6587\u4ef6\u5728\u670d\u52a1\u5668\u4e0a\u4e34\u65f6\u5b58\u653e\u7684\u8def\u5f84<\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">PHP\u51fd\u6570<\/span><span style=\"color: #000000;\">move_uploaded_file<\/span><span style=\"color: #000000;\">\u5c06<\/span><span style=\"color: #000000;\">\u7528\u6237\u63d0\u4f9b\u7684\u4e34\u65f6\u6587\u4ef6<\/span><span style=\"color: #000000;\">\u79fb\u52a8<\/span><span style=\"color: #000000;\">\u5230\u4e00\u4e2a\u4f4d\u7f6e<\/span><span style=\"color: #000000;\">\u3002<\/span><span style=\"color: #000000;\">\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b<\/span><span style=\"color: #000000;\">\uff0c\u76ee\u7684\u5730\u662f<\/span><span style=\"color: #000000;\">\u670d\u52a1\u5668\u6839\u76ee\u5f55<\/span><span style=\"color: #000000;\">\u4ee5\u4e0b<\/span><span style=\"color: #000000;\">\u3002<\/span><span style=\"color: #000000;\">\u56e0\u6b64\uff0c<\/span><span style=\"color: #000000;\">\u6587\u4ef6\u53ef\u4ee5<\/span><span style=\"color: #000000;\">\u4f7f\u7528<\/span><span style=\"color: #000000;\">\u7684URL<\/span><span style=\"color: #000000;\">\uff0c\u5982\uff1a<\/span><span style=\"color: #000000;\">http:\/\/www.domain.tld\/uploads\/uploadedfile.ext<\/span><span style=\"color: #000000;\">\u8bbf\u95ee<\/span><span style=\"color: #000000;\">\u3002<\/span><span style=\"color: #000000;\">\u5728\u8fd9\u4e2a\u7b80\u5355<\/span><span style=\"color: #000000;\">\u7684<\/span><span style=\"color: #000000;\">\u4f8b\u5b50<\/span><span style=\"color: #000000;\">\u4e2d<\/span><span style=\"color: #000000;\">\uff0c\u6709<\/span><span style=\"color: #000000;\">\u5141\u8bb8<\/span><span style=\"color: #000000;\">\u4e0a\u4f20<\/span><span style=\"color: #000000;\">\u7684<\/span><span style=\"color: #000000;\">\u6587\u4ef6<\/span><span style=\"color: #000000;\">\u7c7b\u578b<\/span><span style=\"color: #000000;\">\u6ca1\u6709\u9650\u5236<\/span><span style=\"color: #000000;\">\uff0c\u56e0\u6b64<\/span><span style=\"color: #000000;\">\u653b\u51fb\u8005\u53ef\u4ee5<\/span><span style=\"color: #000000;\">\u4e0a\u4f20<\/span><span style=\"color: #000000;\">\u4e00\u4e2a<\/span><span style=\"color: #000000;\">\u5e26\u6709\u6076\u610f\u4ee3\u7801<\/span><span style=\"color: #000000;\">\u7684PHP\u6216.NET<\/span><span style=\"color: #000000;\">\u6587\u4ef6<\/span><span style=\"color: #000000;\">\uff0c\u53ef\u5bfc\u81f4<\/span><span style=\"color: #000000;\">\u670d\u52a1\u5668<\/span><span style=\"color: #000000;\">\u88ab\u653b\u51fb<\/span><span style=\"color: #000000;\">\u3002<\/span><br style=\"color: #000000;\" \/><br style=\"color: #000000;\" \/><span style=\"color: #000000;\">\u8fd9<\/span><span style=\"color: #000000;\">\u53ef\u80fd\u770b\u8d77\u6765\u50cf<\/span><span style=\"color: #000000;\">\u5f88\u5e7c\u7a1a<\/span><span style=\"color: #000000;\">\u7684<\/span><span style=\"color: #000000;\">\u4f8b\u5b50<\/span><span style=\"color: #000000;\">\uff0c<\/span><span style=\"color: #000000;\">\u4f46\u6211\u4eec\u5728\u4e00\u4e9bWeb\u5e94\u7528\u4e2d\u8fd8\u771f\u7684<\/span><span style=\"color: #000000;\">\u9047\u5230\u8fc7<\/span><span style=\"color: #000000;\">\u8fd9\u6837\u7684\u4ee3\u7801<\/span><span style=\"color: #000000;\">\u3002<\/span><\/p>\n<h3 id=\"content_h3_5_5\" style=\"color: #000000;\">\u6848\u4f8b2\uff1aMime\u7c7b\u578b\u9a8c\u8bc1<\/h3>\n<p style=\"color: #000000;\">\u53e6\u4e00\u4e2a\u5e38\u89c1\u7684\u9519\u8befWeb\u5f00\u53d1\u4eba\u5458\u786e\u4fdd\u6587\u4ef6\u4e0a\u4f20\u8868\u5355\u65f6\uff0c\u53ea\u68c0\u67e5\u4ecePHP\u8fd4\u56demime\u7c7b\u578b\u3002\u5f53\u4e00\u4e2a\u6587\u4ef6\u88ab\u4e0a\u4f20\u5230\u670d\u52a1\u5668\uff0cPHP\u5c06\u8bbe\u7f6e\u53d8\u91cf$_FILES[&#8216;UploadedFile&#8217;][&#8216;type&#8217;]\u6240\u63d0\u4f9b\u7684Web\u6d4f\u89c8\u5668\u5ba2\u6237\u7aef\u4f7f\u7528\u7684MIME\u7c7b\u578b\u3002\u7136\u800c\uff0c\u6587\u4ef6\u4e0a\u4f20\u8868\u5355\u9a8c\u8bc1\u4e0d\u80fd\u4f9d\u8d56\u4e8e\u8fd9\u4e2a\u503c\u3002\u6076\u610f\u7528\u6237\u53ef\u4ee5\u8f7b\u677e\u5730\u4f7f\u7528\u811a\u672c\u6216\u5176\u4ed6\u4e00\u4e9b\u81ea\u52a8\u5316\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5141\u8bb8\u53d1\u9001HTTP POST\u8bf7\u6c42\uff0c\u8fd9\u8ba9\u4ed6\u9001\u4e00\u4e2a\u5047\u7684mime\u7c7b\u578b\u7684\u6587\u4ef6\u4e0a\u4f20\u3002<\/p>\n<h3 id=\"content_h3_6_5\">\u6848\u4f8b3\uff1a\u9650\u5236\u5371\u9669\u7684\u62d3\u5c55<\/h3>\n<p>\u5728\u53e6\u4e00\u4e2a\u4f8b\u5b50\u91cc\uff0c\u6211\u4eec\u9047\u5230\u4e86\u6587\u4ef6\u4e0a\u4f20\u4f7f\u7528\u9ed1\u540d\u5355\u7684\u505a\u6cd5\uff0c\u4f5c\u4e3a\u4e00\u9879\u5b89\u5168\u63aa\u65bd\u3002\u4ece\u5f00\u53d1\u8005\u6536\u96c6\u5236\u5b9a\u7684\u5371\u9669\u5217\u8868\uff0c\u5982\u679c\u6b63\u5728\u4e0a\u4f20\u7684\u6587\u4ef6\u5305\u542b\u5728\u5217\u8868\u4e2d\uff0c\u8bbf\u95ee\u4f1a\u88ab\u62d2\u7edd\u3002<\/p>\n<p>\u4f7f\u7528\u5371\u9669\u7684\u6587\u4ef6\u6269\u5c55\u540d\uff0c\u5176\u4e3b\u8981\u7f3a\u70b9\u4e4b\u4e00\u662f\uff0c\u5b83\u51e0\u4e4e\u4e0d\u53ef\u80fd\u7f16\u5236\u4e00\u4efd\u5b8c\u6574\u7684\u6e05\u5355\uff0c\u5305\u62ec\u653b\u51fb\u8005\u53ef\u4ee5\u4f7f\u7528\u7684\u6240\u6709\u53ef\u80fd\u7684\u6269\u5c55\u540d\u3002\u4f8b\u5982\u5982\u679c\u4ee3\u7801\u8fd0\u884c\u5728\u6258\u7ba1\u73af\u5883\u4e2d\uff0c\u901a\u5e38\u8fd9\u6837\u7684\u73af\u5883\u8ba9\u5927\u91cf\u7684\u811a\u672c\u8bed\u8a00\uff0c\u5982Perl\uff0cPython\u548cRuby\u7b49\uff0c\u5217\u8868\u53ef\u4ee5\u662f\u65e0\u7a77\u65e0\u5c3d\u7684\u3002<\/p>\n<p><span style=\"color: #000000;\">\u6076\u610f\u7528\u6237\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u7ed5\u8fc7\u8be5\u68c0\u67e5\u4e0a\u4f20\u4e00\u4e2a\u6587\u4ef6\u540d\u4e3a\u201c.htaccess\u201d\uff0c\u5176\u4e2d\u5305\u542b\u7c7b\u4f3c\u4e8e\u4e0b\u9762\u7684\u4e00\u884c\u4ee3\u7801\uff1a<\/span><\/p>\n<pre class=\"lang:default decode:true\">AddType application\/x-httpd-php .jpg<\/pre>\n<p style=\"color: #000000;\">\u4e0a\u9762\u7684\u4ee3\u7801\u884c\uff0c\u6307\u793aApache Web\u670d\u52a1\u5668\u6267\u884cjpg\u56fe\u7247\uff0c\u597d\u50cf\u4ed6\u4eec\u662fPHP\u811a\u672c\u3002\u653b\u51fb\u8005\u73b0\u5728\u53ef\u4ee5\u4e0a\u4f20\u4e00\u4e2ajpg\u6269\u5c55\u540d\u7684\u6587\u4ef6\uff0c\u5176\u4e2d\u5305\u542bPHP\u4ee3\u7801\u3002\u6b63\u5982\u4e0b\u9762\u7684\u622a\u56fe\uff0c\u901a\u8fc7web\u6d4f\u89c8\u5668\u8bf7\u6c42\u4e00\u4e2ajpg\u6587\u4ef6\uff0c\u5176\u4e2d\u5305\u542bPHP\u7684\u547d\u4ee4phpinfo\uff08\uff09\u51fd\u6570\uff0c\u5b83\u4ecd\u7136\u662f\u4eceWeb\u670d\u52a1\u5668\u6267\u884c\uff1a<\/p>\n<p style=\"color: #000000;\"><img loading=\"lazy\" decoding=\"async\" title=\"File Upload Forms Security Threat\" src=\"http:\/\/static.oschina.net\/uploads\/img\/201309\/11101342_cMDb.png\" alt=\"Why File Upload Forms are a Security Threat\" width=\"672\" height=\"362\" \/><\/p>\n<p style=\"color: #000000;\"><strong><strong>\u6848\u4f8b4: \u53cc\u6269\u5c55\u540d (\u7b2c1\u90e8\u5206)<\/strong><\/strong><\/p>\n<p style=\"color: #000000;\">\u672c\u6848\u4f8b\u4e2d\u4f7f\u7528\u7684\u5b89\u5168\u7b56\u7565\u548c\u6848\u4f8b3\u4e2d\u6240\u4f7f\u7528\u7684\u975e\u5e38\u76f8\u8fd1. \u5c3d\u7ba1\u65b9\u5f0f\u6362\u6210\u4e86\u7b80\u5355\u7684\u68c0\u67e5\u6587\u4ef6\u540d\u5177\u6709\u7684\u6269\u5c55\u540d, \u5f00\u53d1\u8005\u901a\u8fc7\u5728\u6587\u4ef6\u540d\u4e2d\u67e5\u627e \u2018.\u2019 \u5b57\u7b26\u5e76\u63d0\u53d6\u70b9\u53f7\u4e4b\u540e\u7684\u5b57\u7b26\u4e32\u6765\u5f97\u5230\u6587\u4ef6\u6269\u5c55\u540d.<\/p>\n<p style=\"color: #000000;\">\u7ed5\u8fc7\u8be5\u9014\u5f84\u7684\u65b9\u6cd5\u6709\u70b9\u513f\u590d\u6742, \u4f46\u662f\u4ecd\u7136\u662f\u73b0\u5b9e\u7684. \u9996\u5148, \u8ba9\u6211\u4eec\u770b\u770b Apache \u662f\u600e\u4e48\u5904\u7406\u5177\u6709\u591a\u91cd\u6269\u5c55\u540d\u7684\u6587\u4ef6\u7684. Apache \u624b\u518c\u4e2d\u6709\u5982\u4e0b\u4e00\u6bb5\u9648\u8ff0:<\/p>\n<pre style=\"color: #000000;\">\u201c\u6587\u4ef6\u53ef\u4ee5\u6709\u591a\u4e2a\u6269\u5c55\u540d, \u8fd9\u4e9b\u6269\u5c55\u540d\u7684\u987a\u5e8f\u4e00\u822c\u60c5\u51b5\u4e0b\u662f\u65e0\u5173\u7d27\u8981\u7684. \u4f8b\u5982: \u5982\u679c\u6587\u4ef6 welcome.html.fr \u88ab\u6620\u5c04\u4e3a\u5185\u5bb9\u7c7b\u578b\u662f text\/html , \u8bed\u8a00\u662f\u6cd5\u8bed\u7684\u8bdd, \u6587\u4ef6welcome.fr.html \u5c06\u88ab\u6620\u5c04\u4e3a\u5b8c\u5168\u76f8\u540c\u7684\u5185\u5bb9. \u5982\u679c\u4e00\u4e2a\u4ee5\u4e0a\u7684\u6269\u5c55\u540d\u6620\u5c04\u5230\u540c\u79cd\u7c7b\u578b\u7684\u5143\u4fe1\u606f\u4e0a, \u90a3\u4e48\u5c06\u4f7f\u7528\u6700\u53f3\u8fb9\u7684\u90a3\u4e2a, \u9664\u4e86\u8bed\u8a00\u548c\u5185\u5bb9\u7f16\u7801. \u6bd4\u5982: .gif \u7684 MIME \u7c7b\u578b\u662f image\/gif , .html \u7684 MIME \u7c7b\u578b\u662f text\/html , \u90a3\u4e48 welcome.gif.html \u7684 MIME \u7c7b\u578b\u5c06\u662ftext\/html .\"<\/pre>\n<p><span style=\"color: #000000;\">\u56e0\u6b64\u4e00\u4e2a\u540d\u4e3a \u2018filename.php.123\u2019 \u7684\u6587\u4ef6\u5c06\u4f1a\u88ab\u89e3\u91ca\u4e3a\u4e00\u4e2a PHP \u6587\u4ef6\u5e76\u88ab\u6267\u884c. \u8fd9\u4ec5\u9650\u4e8e\u6700\u540e\u7684\u90a3\u4e2a\u6269\u5c55\u540d(\u672c\u4f8b\u4e2d\u662f .123)\u6ca1\u6709\u5728 web \u670d\u52a1\u5668\u7684 mime-types \u5217\u8868\u4e2d\u88ab\u6307\u5b9a. web\u5f00\u53d1\u8005\u901a\u5e38\u4e0d\u4f1a\u610f\u8bc6\u5230 Apache \u8fd8\u5b58\u5728\u8fd9\u4e48\u4e00\u4e2a \u2018\u7279\u6027\u2019, \u51fa\u4e8e\u67d0\u4e9b\u539f\u56e0\u6765\u8bf4\u8fd9\u53ef\u80fd\u975e\u5e38\u5371\u9669. \u77e5\u9053\u4e86\u8fd9\u4e2a\u4ee5\u540e, \u4e00\u4e2a\u653b\u51fb\u8005\u53ef\u4ee5\u4e0a\u4f20\u4e00\u4e2a\u540d\u4e3a shell.php.123 \u7684\u6587\u4ef6\u5e76\u7ed5\u8fc7\u6587\u4ef6\u4e0a\u4f20\u4fdd\u62a4\u673a\u5236. \u540e\u53f0\u811a\u672c\u5c06\u4f1a\u8ba1\u7b97\u51fa\u6700\u540e\u7684\u6269\u5c55\u540d (.123)\u5e76\u4f5c\u51fa\u8be5\u6269\u5c55\u540d\u5e76\u4e0d\u5728\u5371\u9669\u7684\u6269\u5c55\u540d\u5217\u8868\u5185\u7684\u7ed3\u8bba. \u8bdd\u867d\u5982\u6b64, \u60f3\u8981\u9884\u9632\u67d0\u6076\u610f\u7528\u6237\u53ef\u80fd\u4f1a\u4f7f\u7528\u7684\u6240\u6709\u968f\u673a\u6269\u5c55\u540d\u6765\u4e0a\u4f20\u4e00\u4e2a\u6587\u4ef6\u5230\u4f60\u7684 web \u670d\u52a1\u5668\u4e0a\u662f\u4e0d\u53ef\u80fd\u7684\u3002<\/span><\/p>\n<p style=\"color: #000000;\"><strong>\u6848\u4f8b5: \u53cc\u6269\u5c55\u540d (\u7b2c2\u90e8\u5206)<\/strong><\/p>\n<p style=\"color: #000000;\">\u4e00\u4e2a\u66f4\u597d\u7684\u589e\u5f3a\u6587\u4ef6\u4e0a\u4f20\u8868\u5355\u7684\u5b89\u5168\u6027\u7684\u9014\u5f84\u5c31\u662f\u767d\u540d\u5355\u673a\u5236. \u5728\u672c\u4f8b\u4e2d, \u5f00\u53d1\u8005\u5b9a\u4e49\u4e86\u4e00\u4e2a \u5df2\u77e5\/\u53ef\u63a5\u53d7 \u7684\u6269\u5c55\u540d\u5217\u8868\u5e76\u4e14\u4e0d\u5141\u8bb8\u4f7f\u7528\u672a\u5728\u540d\u5355\u4e2d\u6307\u5b9a\u7684\u6269\u5c55\u540d.<\/p>\n<p style=\"color: #000000;\">\u7136\u800c, \u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u8be5\u9014\u5f84\u4e0d\u4f1a\u50cf\u671f\u5f85\u7684\u65b9\u5f0f\u90a3\u6837\u5de5\u4f5c. \u5f53 Apache \u88ab\u914d\u7f6e\u4e3a\u6267\u884c PHP \u4ee3\u7801\u7684\u65f6\u5019, \u5b58\u5728\u4e24\u79cd\u65b9\u5f0f\u6765\u5b9e\u73b0\u8be5\u673a\u5236: \u4f7f\u7528 AddHandler \u6307\u4ee4, \u6216\u8005\u4f7f\u7528 AddType \u6307\u4ee4. \u5982\u679c AddHandler \u6307\u4ee4\u88ab\u4f7f\u7528, \u6240\u6709\u5305\u542b \u2018.php\u2019 \u6269\u5c55\u540d\u7684\u6587\u4ef6\u540d(\u4f8b\u5982: \u2018.php\u2019 , \u2018.php.jpg\u2019)\u5747\u88ab\u4f5c\u4e3a PHP \u811a\u672c\u6765\u6267\u884c. \u56e0\u6b64, \u5982\u679c\u4f60\u7684 Apache \u914d\u7f6e\u6587\u4ef6\u5305\u542b\u5982\u4e0b\u4e00\u884c\u7684\u8bdd, \u4f60\u53ef\u80fd\u5f88\u5bb9\u6613\u53d7\u5230\u653b\u51fb:<\/p>\n<pre class=\"lang:default decode:true\">AddHandler php5-script .php<\/pre>\n<p style=\"color: #000000;\">\u4e00\u4e2a\u653b\u51fb\u8005\u53ef\u4ee5\u4e0a\u4f20\u540d\u4e3a \u2018filename.php.jpg\u2019 \u7684\u6587\u4ef6\u5e76\u7ed5\u8fc7\u4fdd\u62a4\u673a\u5236, \u7136\u540e\u6267\u884c\u5176\u4e2d\u7684\u4ee3\u7801.<\/p>\n<p style=\"color: #000000;\"><strong>\u6848\u4f8b 6: \u68c0\u67e5\u56fe\u7247\u5934\u90e8<\/strong><\/p>\n<p style=\"color: #000000;\">\u5f53\u4ec5\u5141\u8bb8\u4e0a\u4f20\u56fe\u7247\u7684\u65f6\u5019, \u5f00\u53d1\u8005\u901a\u5e38\u4f7f\u7528 PHP \u7684\u00a0<strong>getimagesize\u00a0<\/strong>\u51fd\u6570\u6765\u68c0\u6d4b\u56fe\u7247\u7684\u5934\u90e8\u4fe1\u606f. \u8be5\u51fd\u6570\u5728\u88ab\u8c03\u7528\u65f6\u5c06\u4f1a\u8fd4\u56de\u56fe\u7247\u7684\u5c3a\u5bf8, \u5982\u679c\u56fe\u7247\u7ecf\u9a8c\u8bc1\u4e3a\u65e0\u6548\u7684, \u4e5f\u5c31\u662f\u8bf4\u56fe\u7247\u5934\u90e8\u4fe1\u606f\u4e0d\u6b63\u786e, \u5219\u4f1a\u8fd4\u56de false \u503c. \u56e0\u6b64\u4e00\u4e2a\u5f00\u53d1\u8005\u4e00\u822c\u4f1a\u68c0\u67e5\u8be5\u51fd\u6570\u662f\u5426\u8fd4\u56de true \u6216 false, \u5e76\u4e14\u901a\u8fc7\u8be5\u4fe1\u606f\u6765\u9a8c\u8bc1\u4e0a\u4f20\u7684\u6587\u4ef6. \u6240\u4ee5, \u5982\u679c\u4e00\u4e2a\u6076\u610f\u7528\u6237\u8bd5\u7740\u4e0a\u4f20\u4e00\u4e2a\u5185\u5d4c\u6709\u7b80\u5355 PHP shell \u7684 jpg \u6587\u4ef6\u7684\u8bdd, \u8be5\u51fd\u6570\u4f1a\u8fd4\u56de false \u7136\u540e\u4ed6\u5c06\u4e0d\u5141\u8bb8\u4e0a\u4f20\u6b64\u6587\u4ef6. \u7136\u800c, \u5373\u4f7f\u8fd9\u79cd\u65b9\u5f0f\u4e5f\u80fd\u88ab\u5f88\u5bb9\u6613\u7684\u7ed5\u8fc7. \u5982\u679c\u4e00\u4e2a\u56fe\u7247\u5728\u4e00\u4e2a\u56fe\u7247\u7f16\u8f91\u5668\u5185\u6253\u5f00, \u5c31\u5982 Gimp, \u7528\u6237\u5c31\u53ef\u4ee5\u7f16\u8f91\u56fe\u7247\u7684\u6ce8\u91ca\u533a, \u90a3\u513f\u5c31\u80fd\u63d2\u5165 PHP \u4ee3\u7801, \u5c31\u5982\u4e0b\u56fe\u6240\u793a.<\/p>\n<p style=\"color: #000000;\"><a style=\"color: #3e62a6;\" href=\"http:\/\/www.acunetix.com\/wp-content\/uploads\/2012\/10\/PTMFOG0000001242.png\" rel=\"nofollow\"><img loading=\"lazy\" decoding=\"async\" title=\"PTMFOG0000001242\" src=\"http:\/\/static.oschina.net\/uploads\/img\/201309\/11101344_vlca.png\" alt=\"\" width=\"300\" height=\"300\" \/><\/a><\/p>\n<p style=\"color: #000000;\">\u8be5\u56fe\u7247\u4ecd\u7136\u6709\u4e00\u4e2a\u6709\u6548\u7684\u5934\u90e8; \u56e0\u6b64\u5c31\u7ed5\u8fc7\u4e86\u00a0<strong>getimagesize<\/strong>\u00a0\u51fd\u6570\u7684\u68c0\u67e5. \u4ece\u4e0b\u9762\u622a\u56fe\u4e2d\u53ef\u4ee5\u770b\u5230, \u5f53\u4e00\u4e2a\u666e\u901a\u7684 web \u6d4f\u89c8\u5668\u8bf7\u6c42\u8be5\u56fe\u7684\u65f6\u5019, \u63d2\u5165\u5230\u56fe\u7247\u6ce8\u91ca\u533a\u7684 PHP \u4ee3\u7801\u4ecd\u7136\u88ab\u6267\u884c\u4e86:<\/p>\n<p style=\"color: #000000;\"><a style=\"color: #3e62a6;\" href=\"http:\/\/www.acunetix.com\/wp-content\/uploads\/2012\/10\/PTMFOG0000001243.png\" rel=\"nofollow\"><img loading=\"lazy\" decoding=\"async\" title=\"PTMFOG0000001243\" src=\"http:\/\/static.oschina.net\/uploads\/img\/201309\/11101345_kRcM.png\" alt=\"\" width=\"300\" height=\"156\" \/><\/a><\/p>\n<h3 id=\"content_h3_12_5\">\u6848\u4f8b\u4e03\uff1a\u901a\u8fc7.htaccess\u4fdd\u62a4\u4e0a\u4f20\u6587\u4ef6\u5939<\/h3>\n<p>\u53e6\u4e00\u79cd\u6d41\u884c\u7684\u7a7f\u4ef6\u5b89\u5168\u7684\u6587\u4ef6\u4e0a\u4f20\u8868\u5355\u7684\u65b9\u6cd5\u662f\u9002\u7528.htaccess\u4fdd\u62a4\u597d\u4e0a\u4f20\u6587\u4ef6\u5b58\u653e\u7684\u6587\u4ef6\u5939\u3002\u529e\u6cd5\u662f\u9650\u5236\u8fd9\u4e2a\u6587\u4ef6\u5939\u91cc\u7684\u811a\u672c\u6587\u4ef6\u7684\u6267\u884c\u3002\u8fd9\u79cd\u60c5\u5f62\u4e00\u4e0b\uff0c\u4e00\u4e2a.htaccess\u6587\u4ef6\u4e00\u822c\u5305\u542b\u4e0b\u9762\u7684\u4ee3\u7801\uff1a<\/p>\n<pre class=\"lang:default decode:true  \">AddHandler cgi-script .php .php3 .php4 .phtml .pl .py .jsp .asp .htm .shtml .sh .cgi\nOptions \u2013ExecCGI<\/pre>\n<p>\u4e0a\u9762\u7684\u662f\u53e6\u4e00\u79cd\u5f62\u5f0f\u7684\u9ed1\u540d\u5355\uff0c\u672c\u8eab\u5e76\u4e0d\u662f\u5f88\u5b89\u5168\u3002\u5728PHP\u624b\u518c\u4e2d\uff0cmove_uploaded_file\u4e00\u7ae0\u4e2d\uff0c\u6709\u4e00\u4e2awarning:\u82e5\u76ee\u6807\u6587\u4ef6\u5df2\u7ecf\u5b58\u5728\uff0c\u5219\u4f1a\u8986\u76d6\u539f\u6587\u4ef6\u3002<\/p>\n<p>\u56e0\u4e3a\u4e0a\u4f20\u7684\u6587\u4ef6\u80fd\u591f\u800c\u4e14\u4f1a\u8986\u76d6\u5df2\u7ecf\u5b58\u5728\u7684\u540c\u540d\u6587\u4ef6\uff0c\u4e00\u4e2a\u6076\u610f\u7528\u6237\u5f88\u8f7b\u6613\u5c31\u80fd\u7528\u4ed6\u81ea\u5df1\u4fee\u6539\u8fc7\u7684.htaccess\u66ff\u6362\u6389\u539f\u6765\u7684\u3002\u8fd9\u4f7f\u5f97\u4ed6\u53ef\u4ee5\u6267\u884c\u7279\u5b9a\u7684\u5c06\u4f1a\u5e2e\u52a9\u4ed6\u5371\u5bb3\u670d\u52a1\u5668\u7684\u811a\u672c\u3002<\/p>\n<h3 id=\"content_h3_13_5\" style=\"color: #000000;\">\u6848\u4f8b\u516b\uff1a\u5ba2\u6237\u7aef\u9a8c\u8bc1<\/h3>\n<p style=\"color: #000000;\">\u53e6\u4e00\u79cd\u5728\u6587\u4ef6\u4e0a\u4f20\u8868\u5355\u4e2d\u5e38\u7528\u7684\u5b89\u5168\u6280\u672f\u662f\u5728\u5ba2\u6237\u7aef\u9a8c\u8bc1\u4e0a\u4f20\u7684\u6587\u4ef6\u3002\u4e00\u822c\u800c\u8a00\uff0c\u8be5\u6280\u672f\u5728ASP.NET\u5e94\u7528\u4e2d\u66f4\u901a\u7528\u4e00\u4e9b\uff0c\u56e0\u4e3aASP.NET\u63d0\u4f9b\u4e86\u6613\u7528\u7684\u9a8c\u8bc1\u63a7\u4ef6\u3002<\/p>\n<p style=\"color: #000000;\">\u8fd9\u4e9b\u9a8c\u8bc1\u63a7\u4ef6\u5141\u8bb8\u5f00\u53d1\u8005\u5bf9\u8981\u4e0a\u4f20\u7684\u6587\u4ef6\u505a\u6b63\u5219\u68c0\u67e5\uff0c\u4ee5\u67e5\u51fa\u5f85\u4e0a\u4f20\u7684\u6587\u4ef6\u6269\u5c55\u540d\u662f\u5426\u5728\u5141\u8bb8\u5217\u8868\u4e2d\u3002\u4e0b\u9762\u662f\u4e00\u6bb5\u6765\u81ea\u5fae\u8f6f\u7f51\u7ad9\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"lang:asp decode:true \">&lt;asp:FileUpload ID=\"FileUpload1\" runat=\"server\" \/&gt;\n\n  &lt;asp:Button ID=\"Button1\" runat=\"server\" OnClick=\"Button1_Click\" Text=\"Upload File\" \/&gt;&amp;nbsp;\n\n  &lt;asp:Label ID=\"Label1\" runat=\"server\"&gt;&lt;\/asp:Label&gt;\n  &lt;asp:RegularExpressionValidator id=\"RegularExpressionValidator1\" runat=\"server\"\n  ErrorMessage=\"Only mp3, m3u or mpeg files are allowed!\"\n  ValidationExpression=\"^(([a-zA-Z]:)|(\\{2}w+)$?)(\\(w[w].*))\n  +(.mp3|.MP3|.mpeg|.MPEG|.m3u|.M3U)$\" ControlToValidate=\"FileUpload1\"&gt;&lt;\/asp:RegularExpressionValidator&gt;\n\n  &lt;asp:RequiredFieldValidator id=\"RequiredFieldValidator1\" runat=\"server\"\n  ErrorMessage=\"This is a required field!\"\n  ControlToValidate=\"FileUpload1\"&gt;&lt;\/asp:RequiredFieldValidator&gt;\n  &amp;nbsp;<\/pre>\n<p style=\"color: #000000;\">\u8fd9\u6bb5ASP.NET\u4ee3\u7801\u4f7f\u7528\u4e86\u9a8c\u8bc1\u63a7\u4ef6\uff0c\u6240\u4ee5\u6700\u7ec8\u7528\u6237\u53ea\u88ab\u5141\u8bb8\u4e0a\u4f20.mp3,.mpeg,\u6216\u8005.m3u\u6587\u4ef6\u5230\u670d\u52a1\u5668\u3002\u82e5\u6587\u4ef6\u7c7b\u578b\u548c\u8fd9\u4e09\u4e2a\u6307\u5b9a\u7684\u6587\u4ef6\u7c7b\u578b\u4e0d\u4e00\u81f4\uff0c\u9a8c\u8bc1\u63a7\u4ef6\u5c06\u8dd1\u51fa\u5f02\u5e38\uff0c\u6587\u4ef6\u4e5f\u5c31\u4e0d\u4f1a\u88ab\u4e0a\u4f20\u3002<\/p>\n<p style=\"color: #000000;\">\u7531\u4e8e\u8fd9\u79cd\u6587\u4ef6\u9a8c\u8bc1\u662f\u5728\u5ba2\u6237\u7aef\u5b8c\u6210\u7684\uff0c\u6076\u610f\u7528\u6237\u5f88\u5bb9\u6613\u5c31\u80fd\u7ed5\u8fc7\u8fd9\u4e00\u68c0\u67e5\u3002\u5199\u4e00\u6bb5\u5ba2\u6237\u7aef\u811a\u672c\u6765\u66ff\u6362web\u5e94\u7528\u7684\u9a8c\u8bc1\u811a\u672c\u505a\u9a8c\u8bc1\u5e76\u975e\u4e0d\u53ef\u80fd\u3002\u4e0d\u7528web\u6d4f\u89c8\u5668\uff0c\u5165\u4fb5\u8005\u53ef\u4ee5\u4f7f\u7528\u53ef\u4ee5\u53d1\u9001HTTP POST\u8bf7\u6c42\u7684\u7a0b\u5e8f\u6765\u5b9e\u73b0\u4e0a\u4f20\u6587\u4ef6\u3002<\/p>\n<h3 id=\"content_h3_15_5\">\u63a8\u8350\u7684\u89e3\u51b3\u65b9\u6848<\/h3>\n<p>\u5728\u5141\u8bb8\u4e0a\u4f20\u6587\u4ef6\u7684\u7f51\u7ad9\u548cweb\u5e94\u7528\u4e2d\uff0c\u5e94\u5f53\u5e94\u7528\u4e0b\u9762\u7684\u4e00\u7cfb\u5217\u6700\u4f73\u5b9e\u8df5\u65b9\u6cd5\u3002\u8fd9\u4e9b\u5b9e\u8df5\u65b9\u6cd5\u5c06\u6709\u52a9\u4e8e\u4f60\u4fdd\u8bc1web\u5e94\u7528\u7684\u4e0a\u4f20\u6587\u4ef6\u7684\u5b89\u5168\u6027\u3002<\/p>\n<ul>\n<li>\u5b9a\u4e49\u4e00\u4e2a.htaccess\u6587\u4ef6\uff0c\u53ea\u5141\u8bb8\u8bbf\u95ee\u6307\u5b9a\u6269\u5c55\u540d\u7684\u6587\u4ef6\u3002<\/li>\n<li>\u4e0d\u8981\u628a.htaccess\u6587\u4ef6\u548c\u4e0a\u4f20\u6587\u4ef6\u653e\u5728\u540c\u4e00\u4e2a\u76ee\u5f55\u91cc\uff0c\u5e94\u8be5\u653e\u5728\u7236\u76ee\u5f55\u91cc\u3002<\/li>\n<li>\u4e00\u4e2a\u5178\u578b\u7684\u53ea\u5141\u8bb8\u00a0gif, jpg, jpeg \u548c png\u6587\u4ef6\u7684.htaccess\u6587\u4ef6\u5e94\u5f53\u5305\u542b\u4e0b\u9762\u7684\u4ee3\u7801(\u6839\u636e\u4f60\u7684\u9700\u6c42\u505a\u8c03\u6574)\u3002\u8fd9\u6837\u4e5f\u80fd\u963b\u6b62\u53cc\u6269\u5c55\u540d\u653b\u51fb\u3002<\/li>\n<\/ul>\n<p style=\"padding-left: 30px;\">deny from all<br \/>\n&lt;Files ~ &#8220;^w+.(gif|jpe?g|png)$&#8221;&gt;<br \/>\norder deny,allow<br \/>\nallow from all<br \/>\n&lt;\/Files&gt;<\/p>\n<ul style=\"color: #000000;\">\n<li>\u5982\u679c\u53ef\u80fd\uff0c\u628a\u6587\u4ef6\u4e0a\u4f20\u5230root\u76ee\u5f55\u4ee5\u5916\u7684\u76ee\u5f55\u91cc\u3002<\/li>\n<li><span style=\"color: #ff0000;\">\u7981\u6b62\u8986\u76d6\u5df2\u5b58\u5728\u7684\u6587\u4ef6\uff08\u4ee5\u963b\u6b62.htaccess\u8986\u76d6\u653b\u51fb\uff09<\/span><\/li>\n<li>\u521b\u5efa\u4e00\u4e2amime-type<span style=\"color: #ff0000;\"><strong>\u767d\u540d\u5355\u5217\u8868<\/strong><\/span>\u3002(\u53ea\u5141\u8bb8\u8fd9\u4e2a\u5217\u8868\u91cc\u7684Mime-type)<\/li>\n<li><span style=\"color: #ff0000;\">\u751f\u6210\u4e00\u4e2a\u968f\u673a\u7684\u6587\u4ef6\u540d<\/span>\uff0c\u5e76\u4e14\u52a0\u4e0a\u6b64\u524d\u751f\u6210\u7684\u6587\u4ef6\u6269\u5c55\u540d\u3001<\/li>\n<li><span style=\"color: #ff0000;\">\u4e0d\u8981\u53ea\u4f9d\u8d56\u5ba2\u6237\u7aef\u9a8c\u8bc1\uff0c\u8fd9\u4e0d\u591f\u3002\u7406\u60f3\u7684\u662f\u65e2\u6709\u5ba2\u6237\u7aef\u9a8c\u8bc1\u4e5f\u6709\u670d\u52a1\u5668\u7aef\u9a8c\u8bc1\u3002<\/span><\/li>\n<\/ul>\n<h3 id=\"content_h3_16_5\" style=\"color: #000000;\">\u603b\u7ed3<\/h3>\n<p style=\"color: #000000;\">\u5982\u4e0a\u6240\u8ff0\uff0c\u6076\u610f\u7528\u6237\u6709\u5f88\u591a\u624b\u6bb5\u7ed5\u8fc7\u6587\u4ef6\u4e0a\u4f20\u8868\u5355\u5b89\u5168\u9a8c\u8bc1\u3002\u56e0\u6b64\uff0c\u5728web\u5e94\u7528\u4e2d\u5b9e\u73b0\u6587\u4ef6\u4e0a\u4f20\u8868\u5355\u65f6\uff0c\u5e94\u5f53\u9075\u5faa\u6b63\u786e\u7684\u5b89\u5168\u6307\u5bfc\uff0c\u5e76\u4e14\u505a\u6070\u5f53\u7684\u6d4b\u8bd5\u3002\u6240\u4ee5\u53ef\u4ee5\u4f7f\u7528WVS\u534f\u52a9\u8fdb\u884c\u5b89\u5168\u6d4b\u8bd5\u3002<\/p>\n<p>\u8bd1\u6587\u94fe\u63a5\uff1a<a href=\"http:\/\/www.oschina.net\/translate\/upload-forms-threat\" target=\"_blank\">\u4e3a\u4ec0\u4e48\u6587\u4ef6\u4e0a\u4f20\u8868\u5355\u662f\u4e3b\u8981\u7684\u5b89\u5168\u5a01\u80c1<\/a><\/p>\n<p>\u539f\u6587\u94fe\u63a5\uff1a<a href=\"http:\/\/www.acunetix.com\/websitesecurity\/upload-forms-threat\/\" target=\"_blank\">Why File Upload Forms are a Major Security Threat<\/a><\/p>\n<p>&#8212;<\/p>\n<p><span style=\"color: #000000;\">\u914d\u7f6e\u539f\u5219\uff1a<\/span><br style=\"color: #000000;\" \/><span style=\"color: #000000;\">\u670d\u52a1\u5668\u7aef\uff0cWeb\u7528\u6237\u6743\u9650\uff1a\u6709\u5199\u5165\u6743\u9650\u7684\u76ee\u5f55\uff0c\u4e0d\u7ed9\u52a8\u6001\u811a\u672c\u7684\u6267\u884c\u6743\uff0c\u6709\u6267\u884c\u6743\u7684\u76ee\u5f55\uff0c\u4e0d\u7ed9\u5199\u5165\u6743\u3002<\/span><\/p>\n<p>{<span style=\"color: #000000;\">\u4e0a\u4f20\u7684\u6587\u4ef6\u6700\u597d\u662f\u4e0d\u8981\u653e\u5230Web\u5e94\u7528\u7684\u76ee\u5f55\u4e0b\uff0c\u800c\u662f\u653e\u5728\u53e6\u5916\u7684\u4e00\u4e2a\u72ec\u7acb\u7684\u7a7a\u95f4\uff0c\u7136\u540e\u901a\u8fc7\u53ef\u63a7\u5236\u7684\u4ee3\u7801\u8bbf\u95ee\u6587\u4ef6\u7684\u5185\u5bb9\u3002<\/span>}<\/p>\n<p>\u4e4b\u524dCasperKid\u5199\u8fc7\u4e00\u7bc7PDF\u6587\u6863\uff0c\u8be6\u7ec6\u7684\u8bf4\u660e\u4e86\u6587\u4ef6\u4e0a\u4f20\u653b\u51fb\u7684\u4e00\u4e2a\u5927\u4f53\u6846\u67b6\uff0c\u4e24\u76f8\u5bf9\u6bd4\u7740\u770b\u6548\u679c\u4f1a\u597d\u4e9b\uff1a<a href=\"http:\/\/ixyzero.com\/blog\/wp-content\/uploads\/2014\/07\/Upload_Attack_Framework.pdf\">Upload_Attack_Framework<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8ba9\u7528\u6237\u5c06\u6587\u4ef6\u4e0a\u4f20\u5230\u60a8\u7684\u7f51\u7ad9\uff0c\u5c31\u50cf\u662f\u7ed9\u5371\u53ca\u60a8\u7684\u670d\u52a1\u5668\u7684\u6076\u610f\u7528\u6237\u6253\u5f00\u4e86\u53e6\u4e00\u6247\u95e8\u3002\u5373\u4fbf\u5982\u6b64\uff0c\u5728\u4eca\u5929\u7684\u73b0\u4ee3\u4e92\u8054\u7f51\u7684We [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[219],"class_list":["post-487","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","tag-upload"],"views":5529,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/487","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=487"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/487\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}