• html上传图片后,在页面显示上传的图片


    html上传图片后,在页面显示上传的图片

    1、html

       <form class="container" enctype="multipart/form-data" method="post" id='formBox' name="form">
                <input type="file" id="chooseImage" name="file">
                <!-- 保存用户自定义的背景图片 -->
                <img id="cropedBigImg" value='custom' alt="lorem ipsum dolor sit" data-address='' title="自定义背景"/>
          </form>
    

    2、js

     $('#chooseImage').on('change',function(){
            var filePath = $(this).val();         //获取到input的value,里面是文件的路径
            var fileFormat = filePath.substring(filePath.lastIndexOf(".")).toLowerCase();
            // 检查是否是图片
            if( !fileFormat.match(/.png|.jpg|.jpeg/) ) {
                error_prompt_alert('上传错误,文件格式必须为:png/jpg/jpeg');
                return;  
            }
            var src = window.URL.createObjectURL(this.files[0]); //转成可以在本地预览的格式
            $('#cropedBigImg').attr('src',src);
    });
    





    原文:https://blog.csdn.net/qq_29582277/article/details/83185363

  • 相关阅读:
    makefile中宏定义
    make的静态模式
    makefile中两重if判断
    定义命令包
    嵌套执行make
    AcWing 1014. 登山
    AcWing 482. 合唱队形
    AcWing 1027. 方格取数
    AcWing 1016. 最大上升子序列和
    AcWing 187. 导弹防御系统
  • 原文地址:https://www.cnblogs.com/lxwphp/p/10897597.html
Copyright © 2020-2023  润新知