{"id":10085,"date":"2021-08-22T10:43:11","date_gmt":"2021-08-22T02:43:11","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10085"},"modified":"2021-08-23T13:22:13","modified_gmt":"2021-08-23T05:22:13","slug":"file-system-access-api","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2021\/08\/file-system-access-api\/","title":{"rendered":"\u4e0d\u4f7f\u7528file\u7c7b\u578binput\u4e5f\u80fd\u89e6\u53d1\u6587\u4ef6\u4e0a\u4f20"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10085\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10085<\/a> \u946b\u7a7a\u95f4-\u946b\u751f\u6d3b<br \/>\n\u672c\u6587\u6b22\u8fce\u5206\u4eab\u4e0e\u805a\u5408\uff0c\u5168\u6587\u8f6c\u8f7d\u5c31\u4e0d\u5fc5\u4e86\uff0c\u5c0a\u91cd\u7248\u6743\uff0c\u5708\u5b50\u5c31\u8fd9\u4e48\u5927\uff0c\u82e5\u6025\u7528\u53ef\u4ee5\u8054\u7cfb\u6388\u6743\u3002<\/p>\n<p><script>window.wxShareImgUrl = 'https:\/\/www.zhangxinxu.com\/study\/image\/share\/202108-file-access.png';if(!\/zhangxinxu\/.test(location.host)){document.body.addEventListener('mousedown',function(){location.href='https:\/\/www.zhangxinxu.com\/wordpress\/?p=10085'});}<\/script><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202108\/file-api-cover.png\" width=\"480\" height=\"312\" alt=\"\u6587\u4ef6\u5939\u56fe\u7247\" class=\"alignright clip thumb size-medium\" \/><\/p>\n<h3>\u4e00\u3001\u6e29\u6545\u800c\u77e5\u65b0<\/h3>\n<p>\u4f20\u7edf\u5728Web\u7aef\u6587\u4ef6\u4e0a\u4f20\uff0c\u90fd\u662f\u4f7f\u7528<code>file<\/code>\u7c7b\u578b\u7684\u8868\u5355<code>input<\/code>\u6846\uff1a<\/p>\n<pre>&lt;input type=\"file\"&gt;<\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201511\/2015-11-23_222745.png\" width=\"232\" height=\"101\" alt=\"file input\u6846\" class=\"alignnone\"><\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7<code>accept<\/code>\u5c5e\u6027\u6307\u5b9a\u9009\u62e9\u7684\u6587\u4ef6\u7c7b\u578b\uff0c<code>directory<\/code>\u5c5e\u6027\u6307\u5b9a\u662f\u5426\u53ef\u4ee5\u9009\u62e9\u6587\u4ef6\u5939\uff0c<code>capture<\/code>\u5c5e\u6027\u6307\u5b9a\u524d\u7f6e\u6216\u540e\u7f6e\u6444\u50cf\u5934\u3002<\/p>\n<p>\u529f\u80fd\u8fd8\u662f\u5f88\u5f3a\u7684\u3002<\/p>\n<p>\u5177\u4f53\u53ef\u4ee5\u89c1\u6211\u4e4b\u524d\u8fd9\u7bc7\u6587\u7ae0\uff1a\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2015\/11\/html-input-type-file\/\">HTML input type=file\u6587\u4ef6\u9009\u62e9\u4e8c\u4e09\u4e8b<\/a>\u201d<\/p>\n<p>\u4f46\u662f<code>file<\/code>\u8f93\u5165\u6846\u6709\u4e2a\u81f4\u547d\u7684\u7f3a\u70b9\uff0c\u5c31\u662f UI \u592a\u4e11\u4e86\uff0c\u5e76\u4e14\u65e0\u6cd5\u5b9a\u5236\u3002<\/p>\n<p>\u867d\u7136\u4f7f\u7528 <code>&lt;label&gt;<\/code> \u5143\u7d20\u53ef\u4ee5\u6a21\u62df\u70b9\u51fb\u6309\u94ae\uff0c\u901a\u8fc7 <code>for<\/code> \u5c5e\u6027\u6307\u5411<code>file<\/code> input\u5b9e\u73b0\u7c7b\u4f3c\u6548\u679c\uff0c\u4f46\u662f\u5570\u55e6\u4e86\u70b9\u3002<\/p>\n<p>\u90a3\u6709\u6ca1\u6709\u4ec0\u4e48\u529e\u6cd5\u70b9\u51fb\u4e00\u4e2a\u666e\u901a\u7684\u6309\u94ae\uff0c\u4e5f\u80fd\u89e6\u53d1\u6587\u4ef6\u9009\u62e9\u5462\uff1f\u6700\u597d\u53ef\u4ee5\u8bbe\u7f6e\u9009\u62e9\u6587\u4ef6\u5939\u8fd8\u662f\u6587\u4ef6\uff0c\u8bbe\u7f6e\u9009\u62e9\u7684\u6587\u4ef6\u683c\u5f0f\u7c7b\u578b\u3002<\/p>\n<p>\u8fd8\u771f\u6709\uff0c\u73b0\u4ee3Web\u4e0d\u65ad\u53d1\u5c55\uff0c\u51fa\u73b0\u4e86\u4e00\u4e2a\u65b0\u7684API\uff0c\u53eb\u505a File System Access API\uff0c\u53ef\u4ee5\u5b9e\u73b0\u70b9\u51fb\u4efb\u610f\u5143\u7d20\u89e6\u53d1\u6587\u4ef6\u9009\u62e9\u3002<\/p>\n<h3>\u4e8c\u3001showOpenFilePicker\u65b9\u6cd5<\/h3>\n<p>\u5047\u8bbe\u9875\u9762\u4e0a\u6709\u4e2a\u6309\u94ae\uff0c\u5176HTML\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>&lt;button id=\"button\"&gt;\u9009\u62e9\u56fe\u7247&lt;\/button&gt;<\/pre>\n<p>\u5219\u4e0b\u9762\u51e0\u884cJavaScript\u4ee3\u7801\u5c31\u53ef\u4ee5\u5b9e\u73b0\u70b9\u51fb\u6309\u94ae\u51fa\u73b0\u6587\u4ef6\u9009\u62e9\uff1a<\/p>\n<pre>button.addEventListener('click', function () {\r\n    <span style=\"color:green;\">\/\/ \u6253\u5f00\u6587\u4ef6<\/span>\r\n    window.showOpenFilePicker();\r\n});<\/pre>\n<p>\u771f\u662f\u7b80\u5355\u53c8\u7c97\u66b4\uff0c\u76f4\u63a5\u53c8\u4e86\u5f53\u3002<\/p>\n<p><span class=\"hidden\">\/\/zxx: \u5982\u679c\u4f60\u770b\u5230\u8fd9\u6bb5\u6587\u5b57\uff0c\u8bf4\u660e\u4f60\u73b0\u5728\u8bbf\u95ee\u662f\u4f53\u9a8c\u7cdf\u7cd5\u7684\u5783\u573e\u76d7\u7248\u7f51\u7ad9\uff0c\u4f60\u53ef\u4ee5\u8bbf\u95ee\u539f\u6587\u83b7\u5f97\u5f88\u597d\u7684\u4f53\u9a8c\uff1ahttps:\/\/www.zhangxinxu.com\/wordpress\/?p=10085\uff08\u4f5c\u8005\u5f20\u946b\u65ed\uff09<\/span><\/p>\n<p>\u5f53\u7136\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>showDirectoryPicker()<\/code> \u65b9\u6cd5\u6765\u9009\u62e9\u6587\u4ef6\u5939\u3002<\/p>\n<pre>button.addEventListener('click', function () {\r\n    <span style=\"color:green;\">\/\/ \u6253\u5f00\u6587\u4ef6\u5939<\/span>\r\n    window.showDirectoryPicker();\r\n});<\/pre>\n<p>\u7531\u4e8e\u4e24\u4e2aAPI\u53c2\u6570\u548c\u4f5c\u7528\u7c7b\u4f3c\uff0c\u56e0\u6b64\u91cc\u53ea\u8be6\u7ec6\u4ecb\u7ecd\u6587\u4ef6\u7684\u9009\u62e9\u3002<\/p>\n<h4>\u6587\u4ef6\u7c7b\u578b\u3001\u591a\u9009\u4e0e\u5426\u7684\u6307\u5b9a<\/h4>\n<p><code>showOpenFilePicker(options)<\/code> \u65b9\u6cd5\u4e2d\u662f\u53ef\u4ee5\u4f20\u53c2\u7684\uff0c\u5177\u4f53\u652f\u6301\u7684\u53c2\u6570\u5982\u4e0b\uff1a<\/p>\n<p>\u5176\u4e2d\uff0coptions\u662f\u53ef\u9009\u53c2\u6570\uff0c\u652f\u6301\u4e0b\u9762\u8fd9\u4e9b\u5c5e\u6027\uff1a<\/p>\n<dl>\n<dt><strong>multiple<\/strong><\/dt>\n<dd>\u5e03\u5c14\u503c\uff0c\u9ed8\u8ba4\u503c\u662f false \uff0c\u8868\u793a\u53ea\u80fd\u9009\u62e9\u4e00\u4e2a\u6587\u4ef6\u3002<\/dd>\n<dt><strong>excludeAcceptAllOption<\/strong><\/dt>\n<dd>\u5e03\u5c14\u503c\uff0c\u9ed8\u8ba4\u503c\u662f false \uff0c\u8868\u793a\u662f\u5426\u6392\u9664\u4e0b\u9762 types \u4e2d\u7684\u6240\u6709\u7684accept\u6587\u4ef6\u7c7b\u578b\u3002<\/dd>\n<dt><strong>types<\/strong><\/dt>\n<dd>\u53ef\u9009\u62e9\u7684\u6587\u4ef6\u7c7b\u578b\u6570\u7ec4\uff0c\u6bcf\u4e2a\u6570\u7ec4\u9879\u4e5f\u662f\u4e2a\u5bf9\u8c61\uff0c\u652f\u6301\u4e0b\u9762\u4e24\u4e2a\u53c2\u6570\uff1a<\/p>\n<ul>\n<li><code>description<\/code>\uff1a\u8868\u793a\u6587\u4ef6\u6216\u8005\u6587\u4ef6\u5939\u7684\u63cf\u8ff0\uff0c\u5b57\u7b26\u4e32\uff0c\u53ef\u9009\u3002<\/li>\n<li><code>accept<\/code>\uff1a\u63a5\u53d7\u7684\u6587\u4ef6\u7c7b\u578b\uff0c\u5bf9\u8c61\uff0c\u7136\u540e\u5bf9\u8c61\u7684\u952e\u662f\u6587\u4ef6\u7684MIME\u5339\u914d\uff0c\u503c\u662f\u6570\u7ec4\uff0c\u8868\u793a\u652f\u6301\u7684\u6587\u4ef6\u540e\u7f00\u3002\u5177\u4f53\u53ef\u4ee5\u4e0b\u9762\u7684\u793a\u610f\u3002<\/li>\n<\/ul>\n<\/dd>\n<\/dl>\n<p>\u4f8b\u5982\u4e0b\u9762\u7684JS\u4ee3\u7801\u6267\u884c\u5c31\u662f\u53ef\u4ee5\u4e00\u6b21\u6027\u9009\u62e9\u591a\u5f20\u672c\u5730\u684c\u9762\u56fe\u7247\uff1a<\/p>\n<pre>window.showOpenFilePicker({\r\n    types: [{\r\n        description: 'Images',\r\n        accept: {\r\n            'image\/*': ['.png', '.gif', '.jpeg', '.jpg', '.webp']\r\n        }\r\n    }],\r\n    <span style=\"color:green;\">\/\/ \u53ef\u4ee5\u9009\u62e9\u591a\u4e2a\u56fe\u7247<\/span>\r\n    multiple: true\r\n});<\/pre>\n<h3>\u4e09\u3001\u6f14\u793a-\u70b9\u51fb\u6309\u94ae\u9009\u62e9\u5e76\u663e\u793a\u591a\u56fe<\/h3>\n<p>\u4e0a\u9762\u77e5\u9053\u4e86\u9009\u62e9\u6587\u4ef6\uff0c\u4f46\u662f\u5982\u4f55\u5904\u7406\u9009\u62e9\u540e\u7684\u6587\u4ef6\u5462\uff0c\u4e0b\u9762\u6709\u4e2a\u4f8b\u5b50\uff0c\u5bf9\u5927\u5bb6\u5b66\u4e60\u4f1a\u5f88\u6709\u5e2e\u52a9\u3002<\/p>\n<p>\u5b8c\u6574\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>&lt;button id=\"button\"&gt;\u9009\u62e9\u56fe\u7247&lt;\/button&gt;\r\n&lt;p id=\"output\"&gt;&lt;\/p&gt;<\/pre>\n<pre>button.addEventListener('click', async function () {\r\n    <span style=\"color:green;\">\/\/ \u6253\u5f00\u6587\u4ef6<\/span>\r\n    const arrFileHandle = await window.showOpenFilePicker({\r\n        types: [{\r\n            accept: {\r\n                'image\/*': ['.png', '.gif', '.jpeg', '.jpg', '.webp']\r\n            }\r\n        }],\r\n        <span style=\"color:green;\">\/\/ \u53ef\u4ee5\u9009\u62e9\u591a\u4e2a\u56fe\u7247<\/span>\r\n        multiple: true\r\n    });\r\n    \r\n    <span style=\"color:green;\">\/\/ \u904d\u5386\u9009\u62e9\u7684\u6587\u4ef6<\/span>\r\n    for (const fileHandle of arrFileHandle) {\r\n        <span style=\"color:green;\">\/\/ \u83b7\u53d6\u6587\u4ef6\u5185\u5bb9<\/span>\r\n        const fileData = await fileHandle.getFile();\r\n        <span style=\"color:green;\">\/\/ \u8bfb\u6587\u4ef6\u6570\u636e<\/span>\r\n        const buffer = await fileData.arrayBuffer();\r\n        <span style=\"color:green;\">\/\/ \u8f6c\u6210Blod url\u5730\u5740<\/span>\r\n        let src = URL.createObjectURL(new Blob([buffer]));\r\n        <span style=\"color:green;\">\/\/ \u5728\u9875\u9762\u4e2d\u663e\u793a<\/span>\r\n        output.insertAdjacentHTML('beforeend', `&lt;img src=\"${src}\"&gt;`);\r\n    }\r\n});<\/pre>\n<p>\u8fd9\u4e2a\u4f8b\u5b50\u6709\u5bf9\u5e94\u7684demo\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202108\/button-picker-file-upload.php\" rel=\"noopener\" target=\"_blank\">\u6587\u4ef6\u8bbf\u95eeAPI \u89e6\u53d1\u56fe\u7247\u9009\u62e9demo<\/a><\/p>\n<p>\u70b9\u51fbdemo\u9875\u9762\u8fd9\u4e2a\u84dd\u8272\u6309\u94ae\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202108\/2021-08-22_002014.png\" width=\"397\" height=\"199\" alt=\"\u70b9\u51fb\u84dd\u8272\u6309\u94ae\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u9009\u62e9\u81ea\u5df1\u7535\u8111\u4e2d\u5bf9\u5e94\u7684\u56fe\u7247\uff0c\u4f8b\u5982\u6211\u9009\u62e9\u4e862\u5f20\u4e0d\u9519\u7684PNG\u56fe\u7247\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202108\/2021-08-22_002117.png\" width=\"396\" height=\"315\" alt=\"\u9009\u62e9\u56fe\u50cf\u622a\u56fe\u793a\u610f\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u7ed3\u679c\u5728Web\u9875\u9762\u4e0a\u6210\u529f\u9884\u89c8\u4e86\u56fe\u7247\u6548\u679c\uff0c\u5982\u4e0b\u622a\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202108\/2021-08-22_002224.png\" width=\"641\" height=\"452\" alt=\"\u9875\u9762\u4e0a\u9884\u89c8\u6548\u679c\u793a\u610f\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u662f\u4e0d\u662f\u8ddf\u4f20\u7edf\u7684file\u6587\u4ef6\u9009\u62e9\u5f88\u7c7b\u4f3c\u3002<\/p>\n<p>\u7531\u4e8e\u8fd9\u4e9b\u5168\u65b0\u7684API\u90fd\u662f\u8d70\u7684Promise\uff0c\u56e0\u6b64\uff0c\u53ef\u4ee5\u4f7f\u7528async\u3001 await\u7b49\u65b0\u7684JS\u8bed\u6cd5\uff0c\u907f\u514d\u5404\u79cd\u4e71\u7cdf\u7cdf\u7684\u56de\u8c03\uff0c\u4ee3\u7801\u66f4\u7b80\u6d01\u66f4\u6613\u8bfb\u4e86\u3002<\/p>\n<p>\u662f\u4e0d\u662f\u5f88\u8d5e\uff01<\/p>\n<h3>\u56db\u3001\u53ef\u60dc\u662f\u4e2a\u65b0API<\/h3>\n<p>\u5bf9\u4e8e\u4e0d\u559c\u6b22HTML\u8868\u5355\u5143\u7d20\uff0c\u559c\u6b22JavaScript\u4ee3\u7801\u4e00\u628a\u68ad\u7684\u5f00\u53d1\u8005\u800c\u8a00\uff0c\u8fd9\u4e2aAPI\u4f1a\u5f88\u4eb2\u8fd1\u5f88\u559c\u6b22\uff0c\u4f46\u662f\uff0c\u9057\u61be\u7684\u662f\uff0c\u8fd9\u4e2aAPI\u51fa\u6765\u7684\u6bd4\u8f83\u65b0\uff0c\u53bb\u5e74\u4e0b\u534a\u5e74\u624d\u51fa\u6765\uff0cSafari\u6d4f\u89c8\u5668\u5e76\u4e0d\u652f\u6301\uff0c\u56e0\u6b64\uff0c\u4e0d\u80fd\u76f4\u63a5\u4f7f\u7528\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202108\/2021-08-22_002815.png\" width=\"487\" height=\"266\" alt=\"\u517c\u5bb9\u6027\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u4e0d\u8fc7\uff0c\u6709\u4e0d\u5c11\u9879\u76ee\u505a\u4e86mix\u6df7\u5408\u5904\u7406\uff0c\u4e5f\u5c31\u662f\u5199\u4e86\u4e2a JS\uff0c\u652f\u6301\u7684\u6d4f\u89c8\u5668\u4f7f\u7528 File System Access API\uff0c\u4e0d\u652f\u6301\u7684\u6d4f\u89c8\u5668\u8fd8\u662f\u4f7f\u7528\u4f20\u7edf\u7684 <code>&lt;input type=\"file\"&gt;<\/code>\uff0c\u4f8b\u5982\u8c37\u6b4c\u5b9e\u9a8c\u5ba4\u7684\u8fd9\u4e2a\u9879\u76ee <a href=\"https:\/\/github.com\/GoogleChromeLabs\/browser-fs-access\" rel=\"noopener\" target=\"_blank\">browser-fs-access<\/a><\/p>\n<p>\u5982\u679c\u662f\u6587\u4ef6\u4fdd\u5b58\u6216\u4e0b\u8f7d\uff0c\u5219\u53ef\u4ee5\u8bd5\u8bd5<code>window.showSaveFilePicker()<\/code>\u8fd9\u4e2a API\uff0c\u6709\u65f6\u5019\u53ef\u4ee5\u4ecb\u7ecd\u4e0b\uff0c\u5f53\u7136\uff0c\u5b9e\u9645\u5f00\u53d1\uff0c\u6587\u4ef6\u4e0b\u8f7d\u80af\u5b9a\u662f\u4f7f\u7528 <a href=\"https:\/\/github.com\/eligrey\/FileSaver.js\/\" rel=\"noopener\" target=\"_blank\">FileSaver.js<\/a>\uff0c\u8fd9\u53ef\u4ee5\u6587\u4ef6\u4e0b\u8f7d\u5f53\u4ec1\u4e0d\u8ba9\u7684\u738b\u8005\uff0c\u6807\u6746\u9879\u76ee\u3002<\/p>\n<h4>\u5176\u4ed6\u9650\u5236<\/h4>\n<ol>\n<li>\u9700\u8981https\u73af\u5883\uff0c\u5982\u679c\u662f\u672c\u5730localhost \u4e0d\u53d7\u6b64\u9650\u5236\u3002<\/li>\n<li>\u4e0d\u80fd\u5728 iframe \u5185\u4f7f\u7528\uff0c\u56e0\u4e3a\u88ab\u8ba4\u4e3a\u4e0d\u5b89\u5168<\/li>\n<\/ol>\n<h3>\u4e94\u3001\u7ed3\u8bed\u788e\u788e\u5ff5<\/h3>\n<p>\u4e0b\u5348\u53c2\u4e0e\u4e86\u6398\u91d1\u7684\u4e00\u4e2a\u76f4\u64ad\u6d3b\u52a8\uff0c\u8bb2\u5173\u4e8e\u5199\u4f5c\u7684\uff0c\u5927\u5bb6\u6709\u5174\u8da3\u53ef\u4ee5\u5173\u6ce8\u4e0b\uff0c\u5e94\u8be5\u6709\u5f55\u64ad\u89c6\u9891\u548cPPT\uff0c\u6d3b\u52a8\u5ba3\u4f20\u9875\u5730\u5740<a href=\"https:\/\/juejin.cn\/post\/6994417198164869133\" rel=\"noopener\" target=\"_blank\">\u662f\u8fd9\u4e2a<\/a>\u3002<\/p>\n<p>\u4eca\u5929\u7684\u884c\u7a0b\u6b63\u597d\u89e3\u7b54\u4e86\u5176\u4e2d\u5173\u4e8e\u5199\u4f5c\u65f6\u95f4\u7684\u95ee\u9898\uff0c\u6211\u4e0b\u5348\u76f4\u64ad\uff0c\u76f4\u64ad\u5b8c\u53bb\u9493\u9c7c\uff0c\u9493\u5b8c\u9c7c\u56de\u5bb6\u5403\u996d\uff0c\u5403\u665a\u996d\u5c31\u5199\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u65f6\u95f4\u5c31\u662f\u8fd9\u4e48\u6765\u7684\uff0c\u7ba1\u7406\u597d\uff0c\u4e0b\u76ee\u6807\uff0c\u4e0d\u505a\u5b8c\u4e0d\u7761\u89c9\u3002<\/p>\n<p>\u4ee5\u4e0a~<\/p>\n<p>\u6bcf\u5929\u5b66\u4e60\u4e00\u4e2aAPI\uff0c\u65e5\u79ef\u6708\u7d2f\uff0c\u8fc7\u51e0\u5e74\u5c31\u662f\u57fa\u7840API\u5de8\u4f6c\u5566\u3002<\/p>\n<p>\u6b22\u8fce\u8f6c\u53d1\uff0c\u8bc4\u8bba\uff0c\u6587\u4e2d\u6709\u8868\u8ff0\u9519\u8bef\uff0c\u4e5f\u6b22\u8fce\u6307\u6b63\u3002<\/p>\n<p>\u6700\u540e\uff0c\u53cb\u60c5\u9644\u4e0a MDN \u5173\u4e8e File System Access API\u7684\u94fe\u63a5\uff1a<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/File_System_Access_API\" rel=\"noopener\" target=\"_blank\">File_System_Access_API<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/emtion\/emoji\/2764.svg\" width=\"20\" height=\"20\" align=\"absmiddle\"><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u6b22\u8fce\u5206\u4eab\uff0c\u52ff\u5168\u6587\u8f6c\u8f7d\uff0c\u5982\u679c\u5b9e\u5728\u559c\u6b22\uff0c\u53ef\u6536\u85cf\uff0c\u6c38\u4e0d\u8fc7\u671f\uff0c\u4e14\u4f1a\u53ca\u65f6\u66f4\u65b0\u77e5\u8bc6\u70b9\u53ca\u4fee\u6b63\u9519\u8bef\uff0c\u9605\u8bfb\u4f53\u9a8c\u4e5f\u66f4\u597d\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10009\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10085<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202108\/file-api-cover.png\" width=\"160\" height=\"104\" alt=\"\u6587\u4ef6\u5939\u56fe\u7247\" class=\"alignright size-medium\" loading=\"lazy\" \/><\/p>\n<p>\u4ecb\u7ecd\u5168\u65b0\u7684File System Access API\uff0c\u4e5f\u5c31\u662f\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95eeAPI\uff0c\u53ef\u4ee5\u65e0\u9700\u4e13\u95e8\u7684 HTML \u6587\u4ef6\u9009\u62e9\u63a7\u4ef6\uff0c\u7eaf JS \u4ee3\u7801\u5c31\u53ef\u4ee5\u89e6\u53d1\u672c\u5730\u6587\u4ef6\u7684\u9009\u62e9\uff0c\u652f\u6301\u6587\u4ef6\u7c7b\u578b\u7684\u6307\u5b9a\uff0c\u6709demo\uff0c\u6709\u4ee3\u7801\u793a\u610f\uff0c\u53ef\u4ee5\u8fdb\u6765\u4e86\u89e3\u4e0b\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1284],"tags":[1051,873,1466,37,1780,1779,1781],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10085"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=10085"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10085\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=10085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=10085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=10085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}