• input文件上传图形按钮


    <div class="aui-list-item" id="imgFiles">
                                                <!-- 只接受jpg,gif和png格式 -->
                                            <input name="" type="file" multiple="multiple" accept="image/gif, image/jpg, image/png" onchange="showImg(this,3,9)" />
                                            </div>

                                            <div id="imgContainer" style="margin: 10px;"></div>
     
    // 2.7 图片文件上传(imgFiles)
            function showImg(obj,minFileNum,maxFileNum) {
                imgFiles = obj.files
                if (window.File && window.FileList){
                    var fileCount = obj.files.length;
                    if (fileCount < minFileNum || fileCount > maxFileNum){
                        layer.msg('文件个数不符,请重新上传', {time: 1500});
                        return false;
                    }
                }else{
                    layer.msg('你的浏览器不支持上传文件,请升级你的浏览器');
                    return false;
                }
                getImgsByFileReader(document.getElementById("imgContainer"), imgFiles)
            }
            
            // 使用FileReader读取file实例并显示图片
            function getImgsByFileReader(el, files) {
                $(el).html("");
                for (var i = 0; i < files.length; i++) {
                    let img = document.createElement('img')
                    img.setAttribute('style', ' 40px; height: 40px; vertical-align: middle; margin-right: 5px;')
                    el.appendChild(img)
                    var reader = new FileReader()
                    reader.onload = function(e) {
                        img.src = e.target.result
                    }
                    reader.readAsDataURL(files[i]) 
                }
            }
  • 相关阅读:
    Android中Context具体解释 ---- 你所不知道的Context
    JDK6、Oracle11g、Weblogic10 For Linux64Bit安装部署说明
    matplotlib 可视化 —— 定制 matplotlib
    matplotlib 可视化 —— 移动坐标轴(中心位置)
    matplotlib 可视化 —— 移动坐标轴(中心位置)
    matplotlib 可视化 —— 定制画布风格 Customizing plots with style sheets(plt.style)
    matplotlib 可视化 —— 定制画布风格 Customizing plots with style sheets(plt.style)
    指数函数的研究
    指数函数的研究
    指数分布的研究
  • 原文地址:https://www.cnblogs.com/yccg990118/p/11977602.html
Copyright © 2020-2023  润新知