{"id":4755,"date":"2016-01-20T18:12:51","date_gmt":"2016-01-20T10:12:51","guid":{"rendered":"https:\/\/sdeno.com\/?p=4755"},"modified":"2016-01-20T18:13:18","modified_gmt":"2016-01-20T10:13:18","slug":"html-input-typefile%e6%96%87%e4%bb%b6%e9%80%89%e6%8b%a9%e8%a1%a8%e5%8d%95%e5%85%83%e7%b4%a0%e4%ba%8c%e4%b8%89%e4%ba%8b","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=4755","title":{"rendered":"HTML input type=file\u6587\u4ef6\u9009\u62e9\u8868\u5355\u5143\u7d20\u4e8c\u4e09\u4e8b"},"content":{"rendered":"<p>php\u4e0a\u4f20<\/p>\n<p>&nbsp;<\/p>\n<h3>\u4e00\u3001\u826f\u751f- input type=file\u4e0e\u6587\u4ef6\u4e0a\u4f20<\/h3>\n<p>\u672c\u6587\u6240\u8bf4\u7684<code>input type=file<\/code>\u6307\u7684\u662f<code>type<\/code>\u7c7b\u578b\u662f<code>file<\/code>\u7684<code>input<\/code>\u5143\u7d20\uff0c\u6700\u7b80HTML\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">&lt;input type=file&gt;<\/pre>\n<\/div>\n<p>\u4f46\u662f\uff0c\u4e3a\u4e86\u4e60\u60ef\uff0c\u6211\u4eec\u591a\u5199\u6210\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">&lt;input type=\"file\"&gt;<\/pre>\n<\/div>\n<p>\u5728HTML5\u51fa\u73b0\u4e4b\u524d(XHTML)\uff0c\u6211\u4eec\u7684\u95ed\u5408\u89c4\u5219\u5219\u6709\u4e9b\u51fa\u5165\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">&lt;input type=\"file\" \/&gt;<\/pre>\n<\/div>\n<p>\u987e\u540d\u601d\u4e49\uff0c\u9009\u62e9\u6587\u4ef6\uff0c\u5e76\u4e0a\u4f20\u6587\u4ef6\u3002<\/p>\n<p>\u5728\u4e07\u6076\u7684\u65e7\u65f6\u4ee3\uff0cHTML5\u8fd8\u6ca1\u6709\u51fa\u73b0\u4e4b\u524d\uff0c\u539f\u751f\u7684<code>file<\/code>\u00a0<code>input<\/code>\u8868\u5355\u5143\u7d20\u53ea\u80fd\u8ba9\u6211\u4eec\u4e00\u6b21\u4e0a\u4f20\u4e00\u5f20\u56fe\u7247\u3002\u65e0\u6cd5\u6ee1\u8db3\u4e00\u6b21\u4e0a\u4f20\u591a\u56fe\u7684\u4ea4\u4e92\u9700\u6c42\uff0c\u6240\u4ee5\uff0c\u5f88\u591a\u573a\u666f\uff0c\u5c31\u88abswfupload.js\u7ed9\u53d6\u4ee3\u4e86\uff0c\u6709\u70b9\u9010\u6e10\u6de1\u51fa\u4eba\u4eec\u89c6\u91ce\u7684\u611f\u89c9\u3002<\/p>\n<p>\u7136\uff0c\u6280\u672f\u53d1\u5c55\uff0c\u65e5\u65b0\u6708\u5f02\uff0c\u4e09\u5341\u5e74\u6cb3\u4e1c\uff0c\u4e09\u5341\u5e74\u6cb3\u897f\u3002\u968f\u7740\u539f\u751fHTML5\u8868\u5355\u5bf9\u591a\u56fe(<code>multiple<\/code>\u5c5e\u6027)\u3001\u4e0a\u4f20\u524d\u9884\u89c8\uff0c<a style=\"color: #34538b;\" href=\"http:\/\/www.zhangxinxu.com\/wordpress\/2013\/10\/understand-domstring-document-formdata-blob-file-arraybuffer\/\">\u4e8c\u8fdb\u5236\u4e0a\u4f20<\/a>\u7b49\u652f\u6301\u8d8a\u6765\u8d8a\u5e7f\u6cdb\uff0c\u539f\u751f\u7684<code>file<\/code>\u00a0<code>input<\/code>\u8868\u5355\u5143\u7d20\u53c8\u8fce\u6765\u4e86\u65b0\u7684\u5347\u7ea7\uff0cflash\u4e3a\u80cc\u666f\u7684swfupload.js\u6ce8\u5b9a\u8981\u843d\u5bde\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u5bf9\u4e8ePC\u9879\u76ee\uff0cIE8-IE9\u6d4f\u89c8\u5668\u8fd8\u662f\u4e0d\u80fd\u5ffd\u7565\u7684\u3002\u6240\u4ee5\uff0c\u73b0\u5728\uff0c\u5f88\u6d41\u884c\u7684\u4e00\u79cd\u5904\u7406\u65b9\u5f0f\uff0c\u5c31\u662fHTML5 file\u4e0a\u4f20\u548cflash swfupload\u4e0a\u4f20\u4e00\u8d77\u6574\u5408\u7684\u6a21\u5f0f\uff0c\u4f18\u5148\u4f7f\u7528\u539f\u751fHTML5\u4e0a\u4f20\uff0c\u4e0d\u652f\u6301\u7684\uff0c\u4f7f\u7528flash\u4e0a\u4f20\u3002\u6211\u4e4b\u524d\u6709\u7bc7\u5173\u4e8eHTML5\u4e0a\u4f20\u7684\u6587\u7ae0\uff0c\u6bcf\u5929\u8bbf\u95ee\u91cf\u5f88\u9ad8\u7684\uff1a\u201c<a style=\"color: #34538b;\" href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=1923\">\u57fa\u4e8eHTML5\u7684\u53ef\u9884\u89c8\u591a\u56fe\u7247Ajax\u4e0a\u4f20<\/a>\u201d\uff0c\u5927\u5bb6\u6709\u5174\u8da3\u53ef\u4ee5\u770b\u770b\u3002<\/p>\n<h3>\u4e8c\u3001\u83b2\u5b89-\u539f\u751finput\u4e0a\u4f20\u4e0e\u8868\u5355form\u5143\u7d20<\/h3>\n<p>\u5982\u679c\u60f3\u4f7f\u7528\u6d4f\u89c8\u5668\u539f\u751f\u7279\u6027\u5b9e\u73b0\u6587\u4ef6\u4e0a\u4f20(\u5982\u56fe\u7247)\u6548\u679c\uff0c\u7236\u7ea7\u7684<code>form<\/code>\u5143\u7d20\u6709\u4e2a\u4e1c\u897f\u4e0d\u80fd\u4e22\uff0c\u5c31\u662f\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">enctype=\"multipart\/form-data\"<\/pre>\n<\/div>\n<p><code>enctype<\/code>\u5c5e\u6027\u89c4\u5b9a\u5728\u53d1\u9001\u5230\u670d\u52a1\u5668\u4e4b\u524d\u5e94\u8be5\u5982\u4f55\u5bf9\u8868\u5355\u6570\u636e\u8fdb\u884c\u7f16\u7801\uff0c\u9ed8\u8ba4\u7684\u7f16\u7801\u662f\uff1a\u201d<code>application\/x-www-form-urlencoded<\/code>\u201c\u3002\u5bf9\u4e8e\u666e\u901a\u6570\u636e\u662f\u633a\u9002\u7528\u7684\uff0c\u4f46\u662f\uff0c\u5bf9\u4e8e\u6587\u4ef6\uff0c\u79d1\u79d1\uff0c\u5c31\u4e0d\u80fd\u4e71\u7f16\u7801\u4e86\uff0c\u8be5\u4ec0\u4e48\u5c31\u662f\u4ec0\u4e48\uff0c\u53ea\u80fd\u4f7f\u7528<code>multipart\/form-data<\/code>\u4f5c\u4e3a<code>enctype<\/code>\u5c5e\u6027\u503c\u3002<\/p>\n<p>\u65e0\u8bba\u662f\u65e7\u65f6\u4ee3\u7684\u5355\u56fe\u4e0a\u4f20\uff0c\u8fd8\u662fHTML5\u4e2d\u7684\u591a\u56fe\u4e0a\u4f20\uff0c\u5747\u662f\u5982\u6b64\u3002<\/p>\n<h3>\u4e09\u3001\u6cbf\u89c1-\u539f\u751ffile input\u56fe\u7247\u4e0a\u4f20\u524d\u9884\u89c8\u4e0eAjax\u4e0a\u4f20<\/h3>\n<p>\u6587\u4ef6\uff0c\u5c24\u5176\u56fe\u7247\uff0c\u4e0a\u573a\u524d\u80fd\u591f\u9884\u89c8\uff0c\u662f\u5f88\u68d2\u7684\u4ea4\u4e92\u4f53\u9a8c\u3002\u4e0d\u8d70\u670d\u52a1\u5668\uff0c\u4e0d\u8017\u8d39\u6d41\u91cf\uff0c\u591a\u68d2\uff01<\/p>\n<p>\u7406\u60f3\u867d\u597d\uff0c\u5b9e\u73b0\u8d77\u6765\u2026\u2026<\/p>\n<p>\u5728HTML5\u8fd8\u6ca1\u51fa\u73b0\u7684\u65e7\u65f6\u4ee3\uff0c\u53ea\u6709\u4f4e\u7248\u672c\u7684IE\u6d4f\u89c8\u5668\u8c8c\u4f3c\u6709\u65b9\u6cd5\uff0c\u4f7f\u7528\u79c1\u6709\u7684\u6ee4\u955c\uff0c\u8d85\u8d8a\u5b89\u5168\u7684\u9650\u5236\uff08\u5176\u5b9e\u662f\u5229\u7528\u4e86\u4e0d\u597d\u7684\u4e1c\u897f\uff09\uff0c\u5b9e\u73b0\u56fe\u7247\u76f4\u63a5\u9884\u89c8\uff1b\u4f46\u662f\u5462\uff0c\u90a3\u4e2a\u65f6\u5019\uff0cChrome, FireFox\u6ca1\u6709\u8fd9\u4e00\u51fa\uff0c\u4e8e\u662f\uff0c\u60f3\u8981\u4f7f\u7528\u539f\u751ffile input\u5b9e\u73b0\u56fe\u7247\u7684\u4e0a\u4f20\u524d\u9884\u89c8\uff0c\u517c\u5bb9\u6027\u574e\u5f88\u96be\u8de8\u8fc7\u53bb\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u540e\u6765\uff0cHTML5\u6765\u4e86\uff0c\u6211\u4eec\u51fa\u73b0\u4e86\u8f6c\u673a\uff0cIE10+\u4ee5\u53ca\u5176\u4ed6\u73b0\u4ee3\u6d4f\u89c8\u5668\uff0c\u53ef\u4ee5\u8ba9\u6211\u4eec\u76f4\u63a5\u8bfb\u53d6\u56fe\u7247\u7684\u6570\u636e\uff0c\u7136\u540e\u5728\u9875\u9762\u4e0a\u5448\u73b0\uff0c\u5b9e\u73b0\u4e86\u4e0a\u4f20\u524d\u9884\u89c8\uff1b\u52a0\u4e0a\u4e4b\u524d\u8001IE\u7684\u6ee4\u955c\u7b56\u7565\uff0c\u8c8c\u4f3c\uff0c\u53ef\u884c\u3002\u4f46\u662f\u5462\u4f46\u662f\uff0c\u8001\u7684IE\u6d4f\u89c8\u5668\u53ea\u80fd\u6700\u591a\u4e00\u6b21\u9009\u62e9\u4e00\u4e2a\u6587\u4ef6\uff0c\u56e0\u6b64\uff0c\u53ea\u6709\u5355\u56fe\u4e0a\u4f20\u7684\u65f6\u5019\uff0c\u5927\u5bb6\u53ef\u4ee5\u8003\u8651\u8003\u8651\u3002<\/p>\n<p>\u4f20\u7edf\u7684form\u63d0\u4ea4\uff0c\u662f\u8981\u6539\u53d8\u9875\u9762\u6d41\u7684\uff0c\u4e5f\u5c31\u662f\u5237\u65b0\u540e\u8df3\u8f6c\u3002\u597d\u7684\u4f53\u9a8c\u5e94\u8be5\u662f\u8d70Ajax\u4ea4\u4e92\u7684\u3002HTML5\u91cc\u9762\u652f\u6301\u4e8c\u8fdb\u5236formData\u6570\u636e\u63d0\u4ea4\uff0c\u56e0\u6b64\uff0c\u53ef\u4ee5\u4ece\u5bb9Ajax\u63d0\u4ea4\u4e0a\u4f20\u7684\u6587\u4ef6\u6570\u636e\uff1b\u90a3\u8001\u65e7\u7684IE\u6d4f\u89c8\u5668\u600e\u4e48\u529e\uff1f<\/p>\n<p>\u4e00\u822c\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>form\u5143\u7d20\u65b0\u589e<code>target<\/code>\u5c5e\u6027\uff0c\u5176\u503c\u6307\u5411\u9875\u9762\u5185\u9690\u85cf\u7684\u4e00\u4e2a<code>&lt;iframe&gt;<\/code>\u5143\u7d20\u7684<code>id<\/code>, \u5982\u4e0b\u793a\u610f\uff1a\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">&lt;form action=\"\" method=\"post\" enctype=\"multipart\/form-data\" <span style=\"color: #cd0000;\">target=\"uploadIframe\"<\/span>&gt;&lt;\r\n&lt;iframe <span style=\"color: #cd0000;\">id=\"uploadIframe\"<\/span>&gt;&lt;\/iframe&gt;<\/pre>\n<\/div>\n<\/li>\n<li>\u5904\u7406<code>&lt;iframe&gt;<\/code>\u5143\u7d20\u7684<code>onload<\/code>\u4e8b\u4ef6\uff0c\u83b7\u5f97\u8fd4\u56de\u5185\u5bb9\uff08\u5982\u4e0b\u4ee3\u7801\u793a\u610f\uff09\uff0c\u5177\u4f53\u7ec6\u8282\u975e\u672c\u6587\u91cd\u70b9\uff0c\u4e0d\u8868\u3002\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">var doc = iframe.contentDocument ? iframe.contentDocument : frames[iframe.id].document;\r\nvar response = doc.body &amp;&amp; doc.body.innerHTML;<\/pre>\n<\/div>\n<\/li>\n<\/ol>\n<p>OK, \u5f53\u7136\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4e0d\u7528\u50cf\u4e0a\u9762\u8fd9\u4e48\u9ebb\u70e6\uff0c\u76f4\u63a5\u4f7f\u7528<a style=\"color: #34538b;\" href=\"https:\/\/github.com\/malsup\/form\" target=\"_blank\">jquery.form.js<\/a>. \u539f\u7406\u5462\uff0c\u5c31\u662f\u4e0a\u9762\u8fd9\u6837\uff0c\u4f46\u662f\uff0c\u4e0d\u9700\u8981\u8fd9\u4e48\u9ebb\u70e6\u3002<\/p>\n<h3>\u56db\u3001\u6069\u548c-\u539f\u751ffile input\u5927\u5c0f\u3001\u6309\u94ae\u6587\u5b57\u7b49UI\u81ea\u5b9a\u4e49<\/h3>\n<p>\u539f\u751f\u7684file input\u4e0d\u6536\u5f85\u89c1\u7684\u53e6\u5916\u4e00\u4e2a\u539f\u56e0\u662f\uff1a\u957f\u7684\u4e11\u8fd8\u4e0d\u597d\u63a7\u5236\u3002<\/p>\n<p>\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u4e0b\u56fe\u8fd9\u4e2a\u201c\u9009\u62e9\u6587\u4ef6\u201d\u8fd9\u51e0\u4e2a\u6587\u5b57\uff0c\u6211\u4eec\u5c31\u4e0d\u597d\u5bf9file\u63a7\u4ef6\u52a8\u5200\u5b50\u5b9e\u73b0\u81ea\u5b9a\u4e49\uff1a<br \/>\n<figure class=\"mdx-lazyload-container\" style=\"max-width:232px\"><div style=\"padding-top:43.534482758621%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"232\" height=\"101\" class=\"alignnone lazyload\" title=\"file input\u6846\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201511\/2015-11-23_222745.png\" alt=\"file input\u6846\"><\/figure><\/p>\n<p>\u600e\u4e48\u529e\u5462\uff1f<\/p>\n<p>\u6709\u4e00\u79cd\u65b9\u6cd5\u662f\u8fd9\u6837\u7684\uff1a<br \/>\n\u8ba9file\u7c7b\u578b\u7684\u5143\u7d20\u900f\u660e\u5ea6<code>0<\/code>\uff0c\u8986\u76d6\u5728\u6211\u4eec\u597d\u770b\u7684\u6309\u94ae\u4e0a\u3002\u7136\u540e\u6211\u4eec\u53bb\u70b9\u51fb\u597d\u770b\u7684\u6309\u94ae\uff0c\u5b9e\u9645\u4e0a\u70b9\u51fb\u662f\u662f<code>file<\/code>\u5143\u7d20\u3002<\/p>\n<p>\u7136\u800c\uff0c\u6b64\u65b9\u6cd5\u6709\u4e00\u4e9b\u4e0d\u8db3\uff1a<\/p>\n<ol>\n<li>\u5c3a\u5bf8\u63a7\u5236\u4e0d\u7075\u6d3b\u3002CSS\u00a0<code>width<\/code>\u5c5e\u6027\u6709\u4e9b\u6d4f\u89c8\u5668\u4e0d\u7ba1\u7528\uff0c\u9700\u8981\u4f7f\u7528<code>size<\/code>\uff0c\u7136\u540e\u9ad8\u5ea6\u63a7\u5236\u4e5f\u4e0d\u7cbe\u51c6\uff0c\u6211\u4eec\u5f88\u96be\u6b63\u597d\u8986\u76d6\u5728\u597d\u770b\u7684\u81ea\u5b9a\u4e49\u6309\u94ae\u4e0a\u3002<\/li>\n<li>\u6837\u5f0f\u4e0d\u597d\u63a7\u5236\uff0c\u6309\u94ae\u7684<code>hover<\/code>\u6001\u4ee5\u53ca<code>active<\/code>\u6001\u4e0d\u597d\u5904\u7406\u3002<\/li>\n<li>HTML\u7ed3\u6784\u9650\u5236\u4ee5\u53ca\u5b9a\u4f4d\u6210\u672c\u3002<\/li>\n<\/ol>\n<p>\u66f4\u597d\u7684\u65b9\u6cd5\u662f\uff0c\u4f7f\u7528<code>label<\/code>\u5143\u7d20\u4e0e<code>file<\/code>\u63a7\u4ef6\u5173\u8054\uff0c\u597d\u5904\u5728\u4e8e\uff1a<\/p>\n<ol>\n<li>\u70b9\u51fb\u81ea\u5b9a\u4e49\u7684\u6f02\u4eae\u6309\u94ae\u5c31\u662f\u70b9\u51fb\u6211\u4eecfile\u63a7\u4ef6\uff1b<\/li>\n<li>\u6ca1\u6709\u5c3a\u5bf8\u63a7\u5236\u4e0d\u7cbe\u786e\u7684\u95ee\u9898\uff1b<\/li>\n<li>\u6ca1\u6709\u4e0d\u80fd\u54cd\u5e94hover\u6001active\u6001\u7684\u95ee\u9898\uff1b<\/li>\n<li>\u6211\u4eec\u7684\u6f02\u4eae\u6309\u94ae\u751a\u81f3\u53ef\u4ee5\u5728form\u8868\u5355\u5143\u7d20\u7684\u5916\u9762\uff0c\u4f8b\u5982\uff1a\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">&lt;label class=\"ui_button ui_button_primary\" for=\"xFile\"&gt;\u4e0a\u4f20\u6587\u4ef6&lt;\/label&gt;\r\n&lt;form&gt;&lt;input type=\"file\" id=\"xFile\"&gt;&lt;\/form&gt;<\/pre>\n<\/div>\n<p>\u6548\u679c\u5982\u4e0b\uff08\u771f\u5b9e\u5b9e\u65f6\u6548\u679c\uff09\uff1a<\/p>\n<p><label class=\"ui_button ui_button_primary\" style=\"color: #ffffff;\" for=\"xFile\">\u4e0a\u4f20\u6587\u4ef6<\/label><\/p>\n<form><input id=\"xFile\" type=\"file\" \/><\/form>\n<\/li>\n<\/ol>\n<h3>\u4e94\u3001\u76c8\u5e74-file\u7c7b\u578b\u63a7\u4ef6\u7684accept\u5c5e\u6027<\/h3>\n<p>input file\u7c7b\u578b\u63a7\u4ef6\u6709\u4e00\u4e2a\u5c5e\u6027\uff0c\u540d\u4e3a<code>accept<\/code>, \u53ef\u80fd\u6709\u4e9b\u5c0f\u4f19\u4f34\u4e0d\u592a\u4e86\u89e3\u3002\u53ef\u4ee5\u7528\u6765\u6307\u5b9a\u6d4f\u89c8\u5668\u63a5\u53d7\u7684\u6587\u4ef6\u7c7b\u578b\uff0c\u4e5f\u5c31\u662f\u7684\u90a3\u4e2a\u6211\u4eec\u6253\u5f00\u7cfb\u7edf\u7684\u9009\u62e9\u6587\u4ef6\u5f39\u6846\u7684\u65f6\u5019\uff0c\u9ed8\u8ba4\u754c\u9762\u4e2d\u5448\u73b0\u7684\u6587\u4ef6\u7c7b\u578b\u3002\u4f8b\u5982\uff1a<code>accept=\"image\/jpeg\"<\/code>\uff0c\u5219\u754c\u9762\u4e2d\u53ea\u6709jpg\u56fe\u7247\uff0c\u5982\u4e0b\u622a\u56fe\uff0c\u540c\u65f6\uff0c\u7a97\u4f53\u53f3\u4e0b\u65b9\u662f\u201c\u81ea\u5b9a\u4e49\u6587\u4ef6\u201d\u6309\u94ae\uff1a<br \/>\n<figure class=\"mdx-lazyload-container\" style=\"max-width:341px\"><div style=\"padding-top:72.727272727273%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"341\" height=\"248\" class=\"alignnone lazyload\" title=\"\u81ea\u5b9a\u4e49\u6587\u4ef6\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201511\/2015-11-23_233735.png\" alt=\"\u81ea\u5b9a\u4e49\u6587\u4ef6\"><\/figure><\/p>\n<p>\u5b9e\u9645\u5f00\u53d1\u7684\u65f6\u5019\uff0c\u5f88\u5c11\u53ea\u5141\u8bb8\u4f20jpg\u56fe\u7247\uff0c\u5e94\u8be5\u90fd\u662f\u53ea\u80fd\u4f20\u56fe\u7247\u7c7b\u578b\uff0c\u6b64\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">accept=\"image\/*\"<\/pre>\n<\/div>\n<p>\u4e8e\u662f\u4e4e\uff0c\u201c\u81ea\u5b9a\u4e49\u6587\u4ef6\u201d\u6309\u94ae\u53d8\u6210\u4e86\u8bed\u4e49\u66f4\u660e\u786e\u7684\u201c\u56fe\u7247\u6587\u4ef6\u201d\uff1a<br \/>\n<figure class=\"mdx-lazyload-container\" style=\"max-width:405px\"><div style=\"padding-top:69.62962962963%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"405\" height=\"282\" class=\"alignnone lazyload\" title=\"\u56fe\u7247\u6587\u4ef6 \" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201511\/2015-11-23_234028.png\" alt=\"\u56fe\u7247\u6587\u4ef6 \"><\/figure><\/p>\n<p><code>accept<\/code>\u5c5e\u6027\u503c\u5176\u5b9e\u662fMIME\u7c7b\u578b, \u4f8b\u5982\u4e0b\u9762\u51e0\u4e2a\u53ef\u80fd\u5e38\u7528\u7684\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">accept=\"application\/pdf\"\r\naccept=\"audio\/x-mpeg\"\r\naccept=\"text\/html\"\r\n.accept=\"video\/x-mpeg2\"<\/pre>\n<\/div>\n<p>\u7136\u540e\uff0c\u591a\u4e2a\u5c5e\u6027\u503c\u4f7f\u7528\u9017\u53f7\u5206\u9694\uff0c\u4f8b\u5982\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">&lt;input accept=\"audio\/*,video\/*,image\/*\"&gt;<\/pre>\n<\/div>\n<h3>\u516d\u3001\u53c8\u53ca-input file\u503c\u7684\u6e05\u9664<\/h3>\n<p>\u73b0\u4ee3\u6d4f\u89c8\u5668\u76f4\u63a5<code>value = \"\"<\/code>, \u6709\u4e9bIE\u6d4f\u89c8\u5668\u8c8c\u4f3c\u4e0d\u884c\uff0c\u597d\u50cf\u4f7f\u7528<code>file.outerHTML = file.outerHTML<\/code>\uff0c\u6211\u81ea\u5df1\u6ca1\u6d4b\u8bd5\u3002<\/p>\n<p>\u4e0d\u8fc7\u6211\u89c9\u5f97\u6bd4\u8f83\u9ebb\u70e6\uff0c\u8fd8\u8981\u5224\u65ad\u6d4f\u89c8\u5668\u4ec0\u4e48\u7684\u3002\u50cf\u672c\u6587\u7684Ajax\u5355\u56fe\u4e0a\u4f20\uff0c\u76f4\u63a5<code>form.reset()<\/code>\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>\u4ee5\u4e0a~<\/p>\n<p><a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/2015\/11\/html-input-type-file\/\" target=\"_blank\">http:\/\/www.zhangxinxu.com\/wordpress\/2015\/11\/html-input-type-file\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>php\u4e0a\u4f20 &nbsp; \u4e00\u3001\u826f\u751f- input type=file\u4e0e\u6587\u4ef6\u4e0a\u4f20 \u672c\u6587\u6240\u8bf4\u7684input type [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,11],"tags":[],"class_list":["post-4755","post","type-post","status-publish","format-standard","hentry","category-php","category-11"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/4755","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4755"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/4755\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}