本帖最后由 taozhiyu 于 2021-12-10 07:21 编辑
很久之前找到个网页版的很好用
https://www.zhangxinxu.com/sp/base64.html
[HTML] 纯文本查看 复制代码 <!doctype html><html><head><meta charset="utf-8"><title>任意文件转base64-直接拖进来</title><style>body{word-break:break-all;margin:0 1em;min-height:100vh;font-family:Consolas,"Andale Mono","Lucida Console","Lucida Sans Typewriter",Monaco,"Courier New",monospace;overflow:hidden}body::before{position:absolute;font-size:50px;content:'任意文件\A拖到这里';white-space:pre;left:50%;top:50%;transform:translate(-50%,-50%);color:gray}</style></head><body><script>window.addEventListener("dragenter",function(a){a.preventDefault()},false);window.addEventListener("dragover",function(a){a.preventDefault()},false);window.addEventListener("drop",function(b){var a=new FileReader();a.onload=function(c){document.body.insertAdjacentHTML("afterBegin","<p>"+c.target.result+"</p>");document.body.classList.remove("empty")};a.readAsDataURL(b.dataTransfer.files[0]);b.preventDefault()},false);</script></body></html>
完整代码也只有几行(格式化后),保存到html直接打开,文件推进去就行 |