<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <input accept="image/*" name="upimage" id="upload_file" type="file">
        <textarea id="base64_output" name="Word" style=" width:820px"></textarea>
        <script type="text/javascript">
            document.getElementById("upload_file").onchange = function () {
                gen_base64();
            };
            function $_(id) {
                    return document.getElementById(id);
            }
            function gen_base64() {
                var file = $_('upload_file').files[0];
                r = new FileReader();  //本地预览
                r.onload = function(){
                    $_('base64_output').value = r.result;
                }
                r.readAsDataURL(file);    //Base64
            }
        </script>
    </body>
</html>

亲测好用!!!

感谢 https://www.cnblogs.com/Strom-HYL/p/6782176.html

相关文章:

  • 2021-11-08
  • 2021-12-03
  • 2022-12-23
  • 2021-11-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-08
  • 2022-12-23
  • 2021-08-27
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
相关资源
相似解决方案