欢迎阅读『Tag标签列表』

上传图片

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    
</head>
<body>
    <form>
        文件: <input type="file" id="myFile"  name ='myfile' onchange="getFileContent();">  <br>
        <input type="submit">
    </form>
    <img src="" alt="">
    <script>
            function getFileContent(){
                var reader = new FileReader();
                var file = document.querySelector('#myFile').files;
                console.log(file);
                reader.readAsDataURL(file[0])
                
                reader.onload = function(){
                    console.log(123);
                    document.querySelector('img').src = reader.result
                }

            }
          

    </script>
</body>
</html>

 

posted @ 2018-12-27 00:22  兔子零-A酱  阅读(136)  评论(0编辑  收藏  举报