{"id":7553,"date":"2019-07-13T14:27:19","date_gmt":"2019-07-13T06:27:19","guid":{"rendered":"https:\/\/sdeno.com\/?p=7553"},"modified":"2020-04-29T18:23:17","modified_gmt":"2020-04-29T10:23:17","slug":"%e5%8f%a6%e5%ad%98%e4%b8%ba","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=7553","title":{"rendered":"\u53e6\u5b58\u4e3a\u6548\u679c"},"content":{"rendered":"<p>js \u53e6\u5b58\u4e3a a \u4e0b\u8f7d html \u4e0b\u8f7d<\/p>\n<figure class=\"mdx-lazyload-container\" style=\"max-width:455px\"><div style=\"padding-top:72.747252747253%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"455\" height=\"331\" class=\"alignnone size-full wp-image-7556 lazyload\" title=\"\u53e6\u5b58\u4e3a\u6548\u679c\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2019\/07\/firefoxd.jpg\" alt=\"https:\/\/sdeno.com\/wp-content\/uploads\/2019\/07\/firefoxd.jpg\" data-srcset=\"https:\/\/sdeno.com\/wp-content\/uploads\/2019\/07\/firefoxd.jpg 455w, https:\/\/sdeno.com\/wp-content\/uploads\/2019\/07\/firefoxd-300x218.jpg 300w\" sizes=\"auto, (max-width: 455px) 100vw, 455px\"><\/figure> <figure class=\"mdx-lazyload-container\" style=\"max-width:992px\"><div style=\"padding-top:9.375%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"992\" height=\"93\" class=\"alignnone size-large wp-image-7557 lazyload\" title=\"\u53e6\u5b58\u4e3a\u6548\u679c\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2019\/07\/firefoxd1.jpg\" alt=\"https:\/\/sdeno.com\/wp-content\/uploads\/2019\/07\/firefoxd1.jpg\" data-srcset=\"https:\/\/sdeno.com\/wp-content\/uploads\/2019\/07\/firefoxd1.jpg 992w, https:\/\/sdeno.com\/wp-content\/uploads\/2019\/07\/firefoxd1-300x28.jpg 300w, https:\/\/sdeno.com\/wp-content\/uploads\/2019\/07\/firefoxd1-768x72.jpg 768w\" sizes=\"auto, (max-width: 992px) 100vw, 992px\"><\/figure> <figure class=\"mdx-lazyload-container\" style=\"max-width:257px\"><div style=\"padding-top:36.575875486381%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"257\" height=\"94\" class=\"alignnone size-large wp-image-7558 lazyload\" title=\"\u53e6\u5b58\u4e3a\u6548\u679c\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2019\/07\/firefoxd2.jpg\" alt=\"https:\/\/sdeno.com\/wp-content\/uploads\/2019\/07\/firefoxd2.jpg\"><\/figure>\n<p><span style=\"color: #ff0000;\">(\u63a8\u8350)\u524d\u7aef\u65b9\u6cd5\uff1a<\/span><\/p>\n<pre>&lt;a href=\"http:\/\/localhost:3000\/upload\/index_logo.gif\" download=\"xxx\"&gt;\u4e0b\u8f7d11&lt;\/a&gt;   \/\/\u4e0b\u8f7d\u540e\u662fxxx.gif<\/pre>\n<p>*\u6ce8\u610f\u6240\u4e0b\u8f7d\u7684\u6587\u4ef6\u5fc5\u987b\u662f\u540c\u57df\u540d\u4e0d\u7136\u65e0\u6cd5\u5b9e\u73b0\u53e6\u5b58\u4e3a\u6548\u679c\uff0c\u4ec5\u4ec5\u4e0d\u517c\u5bb9IE\u3002\u8c37\u6b4c\u3001\u706b\u72d0\uff0cEdge\u517c\u5bb9<\/p>\n<p>&nbsp;<\/p>\n<p>\u5982\u679c\u4e0b\u8f7d\u9700\u8981token\u9a8c\u8bc1\uff0c\u53c2\u8003<a href=\"https:\/\/sdeno.com\/?p=8002\" target=\"_blank\" rel=\"noopener\">https:\/\/sdeno.com\/?p=8002<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\">\u540e\u7aef\u65b9\u6cd5\uff1a<\/span><\/p>\n<p>\u4f8b\u5982php\u9700\u8981\u8bbe\u7f6e<\/p>\n<pre>header('Content-type: image\/jpeg'); \r\nheader(\"Content-Disposition: attachment; filename='download.jpg'\");<\/pre>\n<p>&nbsp;<\/p>\n<p>\u8fd9\u91cc\u4ee5koa2\u4e3a\u6848\u4f8b\uff1a<\/p>\n<p>\u8def\u7531\u8bbe\u7f6e<\/p>\n<pre>router.get('xxxpath', (ctx) =&gt; {\r\n  ctx.set('Content-disposition','attachment;filename=name.txt'); \/\/ \u8bbe\u7f6e\u4f60\u7684\u6587\u4ef6\u540d\r\n  const data = new Buffer('Im a example of text') \/\/ \u521b\u5efa\u4e00\u4e2abuffer\r\n  ctx.body = data \/\/ \u8fd4\u56de\u5728\u54cd\u5e94\u4f53\u91cc\r\n});<\/pre>\n<p>&nbsp;<\/p>\n<p>\u524d\u7aef\u8bbe\u7f6e<\/p>\n<pre>&lt;a onclick=\"window.open('xxxpath')\"&gt;\u4e0b\u8f7d&lt;\/a&gt;  \/\/\u4e0b\u8f7d\u540e\u4f1a\u5f97\u5230\u4e00\u4e2atxt\uff0c\u5185\u5bb9\u662fIm a example of text<\/pre>\n<p>&nbsp;<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e3a\u4e86\u65b9\u4fbf\u5c06\u5176\u4ed6\u6587\u4ef6\u4e5f\u8f6c\u5316\u4e3aBuffer\uff0c\u63a8\u8350\u4f7f\u7528<\/p>\n<pre>npm i\u00a0urllib -S<\/pre>\n<pre>const urllib = require('urllib');\r\n\r\nrouter.get('down',async ctx=&gt;{\r\n  let file = await urllib.request('https:\/\/sdeno.com\/wp-content\/themes\/flat_ui\/img\/icons\/png\/jquery.png');\r\n  ctx.set('Content-disposition','attachment;filename='+'name.jpg');\r\n  ctx.body=file.data; \/\/\u8fd4\u56de\u7684\u662f Buffer\u7c7b\u578b\r\n});<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2016\/04\/know-about-html-download-attribute\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.zhangxinxu.com\/wordpress\/2016\/04\/know-about-html-download-attribute\/<\/a><br \/>\n<audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\ufeff<\/span><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n","protected":false},"excerpt":{"rendered":"<p>js \u53e6\u5b58\u4e3a a \u4e0b\u8f7d html \u4e0b\u8f7d (\u63a8\u8350)\u524d\u7aef\u65b9\u6cd5\uff1a &lt;a href=&#8221;http:\/\/localh [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-7553","post","type-post","status-publish","format-standard","hentry","category-11"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/7553","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=7553"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/7553\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7553"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}