layui-open-上傳文件


<!--選擇文件上傳-->
<script id="upload_file_dialog" type="text/html">
    <div class="layui-form-item">
        <label class="layui-form-label">文件上傳</label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn" onclick="$('input[name=uploadfile]').click();">
                <i class="layui-icon">&#xe67c;</i>上傳文件
            </button>
            <input type="file" name="uploadfile" style="display: none;" />
        </div>
        <label class="layui-form-label" style="width: 100%; text-align: left; padding-left: 110px;color:red;"
            id="uploadFileName">
            文件上傳</label>
    </div>
</script>
//文件上傳change事件
$("input[name=uploadfile][type=file]").on("change", function (e) {
    var filePath = $(this).val();
    filePath = filePath.substring(filePath.lastIndexOf("\\")+1);
    $("#uploadFileName").text(filePath);
});
function selectFileClick() {
    //判斷瀏覽器版本
    if (webim.BROWSER_INFO.type == 'ie' && parseInt(webim.BROWSER_INFO.ver) <= 9) {
        layui.layer.msg('上傳文件暫不支持ie9(含)以下瀏覽器');
        //$('#updli_file_form')[0].reset();
        //$('#upload_file_low_ie_dialog').modal('show');
    } else {
        layui.layer.open({
            title: "文件上傳",
            content: $('#upload_file_dialog').html(),
            area: ['500px', '300px'],
            btn: ['發送', '取消'],
            yes: function (index, layero) {//發送
                uploadFileBoxIndex = index;
                uploadFile(); 
            },
            btn2:function(index, layero) {//取消
                
            }
        });

        //文件上傳change事件
        $("input[name=uploadfile][type=file]").on("change", function (e) {
            var filePath = $(this).val();
            filePath = filePath.substring(filePath.lastIndexOf("\\")+1);
            $("#uploadFileName").text(filePath);
        });
    }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM