首页 > 其他分享 >bootstrap-fileinput 使用

bootstrap-fileinput 使用

时间:2024-07-05 14:09:13浏览次数:12  
标签:false val bootstrap imgPath fileinput video 使用 true

参考文档:http://www.bootstrap-fileinput.com/options.html

视频和图片上传和展示:

<div class="form-group row">
                <label for="video_path" class="col-sm-2 col-form-label"><span class="text-danger">*</span> 视频</label>
                <div class="col-sm-8">
                    <input type="file" class="form-control" name="video_path" id="video_path">
                    <input type="hidden" id="videoPath" name="videoPath" value="{$info.video_path|default=''}">
                    <div class="form-text text-muted m-t-10 small">格式mp4,最好在50M以内,最大不超过100MB,比例16:9,最小尺寸960*540,最佳尺寸1280*720</div>
                </div>
            </div>

            <div class="form-group row">
                <label for="img_path" class="col-sm-2 col-form-label"><span class="text-danger">*</span> 封面图片</label>
                <div class="col-sm-6">
                    <input type="file" class="form-control" name="img_path" id="img_path">
                    <input type="hidden" id="imgPath" name="imgPath" value="{$info.img_path|default=''}">
                    <div class="form-text text-muted m-t-10 small">jpg、jpeg、png,小于等于200KB,尺寸858*429</div>
                </div>
            </div>


<link href="/js/bootstrap-fileinput/themes/explorer-fa/theme.min.css" rel="stylesheet">
<script src="/js/bootstrap-fileinput/themes/explorer-fa/theme.min.js"></script>
<link href="/js/bootstrap-3.4.1/css/bootstrap.css" rel="stylesheet">

<script type="text/javascript">
    $(function () {
        //视频
        var videoPath = $('#videoPath').val();
        if(videoPath===''){
            $("#video_path").fileinput({
                language: 'zh',
                showUpload: false,
                showClose: false,
                dropZoneTitle: '拖拽文件到这里...',
                autoReplace: true,
                allowedFileTypes: ['video'],
                allowedFileExtensions : ['mp4'],
                initialPreviewAsData:true,
                layoutTemplates:{actionDelete: '', actionUpload: '', actionZoom: '', actionDownload: ''}
            });
        }else{
            $("#video_path").fileinput({
                language: 'zh',
                showUpload: false,
                showClose: false,
                dropZoneTitle: '拖拽文件到这里...',
                autoReplace: true,
                allowedFileTypes: ['video'],
                allowedFileExtensions : ['mp4'],
                initialPreviewAsData:true,
                initialPreview: ["{$info.r_path|default=''}"],
                initialPreviewConfig: [{type:"video",filetype:'video/mp4'}],
                layoutTemplates:{actionDelete: '', actionUpload: '', actionZoom: '', actionDownload: ''}
            }).on('filecleared', function (event, data, msg) {
                $('#videoPath').val('');
            }).on("filebatchselected", function(event, files) {
                $('#videoPath').val('');
            });
        }
        //封面图
        var imgPath = $('#imgPath').val();
        if(imgPath===''){
            $("#img_path").fileinput({
                language: 'zh',
                showUpload: false,
                showClose: false,
                dropZoneTitle: '拖拽文件到这里...',
                autoReplace: true,
                allowedFileTypes: ['image'],
                allowedFileExtensions : ['jpg','jpeg','png'],
                initialPreviewAsData:true,
                layoutTemplates:{actionDelete: '', actionUpload: '', actionZoom: ''}
            });
        }else{
            $("#img_path").fileinput({
                language: 'zh',
                showUpload: false,
                showClose: false,
                dropZoneTitle: '拖拽文件到这里...',
                autoReplace: true,
                allowedFileTypes: ['image'],
                allowedFileExtensions : ['jpg','jpeg','png'],
                initialPreviewAsData:true,
                initialPreview: ["{$sCosUrl|default=''}"+imgPath],
                layoutTemplates:{actionDelete: '', actionUpload: '', actionZoom: '', actionDownload: ''}
            }).on('filecleared', function (event, data, msg) {
                $('#imgPath').val('');
            }).on("filebatchselected", function(event, files) {
                $('#imgPath').val('');
            });
        }
    })

    
</script>

bootstrap-fileinput 还提供了 layoutTemplates 渲染模板配置, 只要愿意花时间, 可以自定义大部分功能
给上传的图片添加“打印”按钮

$("#file1").fileinput({
        'uploadUrl': ctx + 'fileUpload',
        overwriteInitial: false,
        initialPreviewAsData: true,
        layoutTemplates : {
            actions: '<div class="file-actions">\n' +
                '    <div class="file-footer-buttons">\n' +
                '        {upload} {delete} {zoom} {other} <button type="button" class="kv-file-print btn btn-sm btn-kv btn-default btn-outline-secondary" title="打印"><i class="glyphicon glyphicon-print"></i></button>' +
                '    </div>\n' +
                '    {drag}\n' +
                '    ' +
                '    <div class="clearfix"></div>\n' +
                '</div>',
        }
    });

 

标签:false,val,bootstrap,imgPath,fileinput,video,使用,true
From: https://www.cnblogs.com/wjs2019/p/18285713

相关文章

  • 从零开始使用WordPress搭建个人网站并一键发布公网详细教程
    文章目录前言1.搭建网站:安装WordPress2.搭建网站:创建WordPress数据库3.搭建网站:安装相对URL插件4.搭建网站:内网穿透发布网站4.1命令行方式:4.2.配置wordpress公网地址5.固定WordPress公网地址5.1.固定地址访问WordPress前言本文主要介绍如何在LinuxUbuntu......
  • ipython的使用技巧整理
    IPython是一个强大的交互式Python环境,提供了许多高级功能和快捷键,以下是非常详细的IPython使用技巧整理,覆盖了每个知识点(但本文是基于有一定基础的同学看的):IPython的使用基础:一、安装与基本操作安装Anaconda建议直接下载安装Anaconda,其中包含丰富的库,以及我们需要使用......
  • ansible使用手册
    Connectionmethodsanddetails—AnsibleCommunityDocumentation1buildyourinventory1.1Thedefaultlocationforthisfileis/etc/ansible/hosts.Youcanspecifyadifferentinventoryfileatthecommandlineusingthe-i<path>optionorinco......
  • 使用systemctl管理磁盘挂载
    1.找到磁盘的UUID首先,找到/dev/sda的UUID。使用blkid命令:blkid/dev/sda输出示例:/dev/sda:UUID="e6c123d8-1234-4b62-9e4b-e2f235d31542"TYPE="ext4"假设UUID是e6c123d8-1234-4b62-9e4b-e2f235d31542。2.创建挂载点确保挂载点/home/nvidia/aibox已经存......
  • 做了一款服务网络安全的多端系统。内置AI(gpt4o)/ai绘画(sd)/ChatTTS,无需登陆免费使用
    上一篇魔盒介绍文章已被我删除,因为本次重新做了产品定位,之前定位有点混乱先上链接之前有个哥们说做了app还不如先做网站,因为不方便下载,这次做了哈。重点:里面有gpt4o,充了几十美元反正也用不完,给大家用了网页端:https://mgb.abyssdawn.com/H5端:https://mgb-h5.abyssdaw......
  • Apache HTTP Server 使用
    安装macOS:brewinstallapache2Ubuntu:sudoaptinstallapache2使用配置文件路径:macOS:/opt/homebrew/etc/httpd/httpd.confUbuntu:/etc/apache2/apache2.confDocumentRoot:macOS:/opt/homebrew/var/wwwUbuntu:/var/wwwmacOS:brewservicesstarthttpd......
  • 使用容器化技术提升返利App的部署效率
    使用容器化技术提升返利App的部署效率大家好,我是免费搭建查券返利机器人省钱赚佣金就用微赚淘客系统3.0的小编,也是冬天不穿秋裤,天冷也要风度的程序猿!今天我们将探讨如何利用容器化技术来提升返利App的部署效率。随着现代软件开发的迅速发展,容器化技术已经成为构建、打包和......
  • 阿里云免费的CI/CD平台(云效平台)使用教程(二) - 创建流水线
     上一篇介绍了在云效平台导入代码的教程,本篇是整个教程的重点,使用云效平台实现CI/CD功能。简介什么是流水线流水线有三个重要的概念,源、构建、部署,简单理解就是选择流水线的原材料,添加制作原材料的步骤,输出成品。在这里原材料就是源代码或者与源代码相关的必要附件。制作......
  • windows安装以及切换使用nodejs多版本
    1安装nvmnvm是一个简单的bash脚本,它是用来管理系统中多个已存的Node.js版本。可以先把系统已有的node卸载掉,也可不卸载,但是以防没必要的冲突,尽量还是卸掉。1.1下载nvm下载地址:https://github.com/coreybutler/nvm-windows/releases,下载.zip后缀的这个文件,下载后解压安装即可......
  • Visual Studio 使用 EditorConfig 定义一致的编码样式
    代码一致性EditorConfig文件设置可在代码库中保持一致的编码样式和约定,无论使用哪种编辑器或IDE。可以控制缩进样式、制表符宽度、行尾字符和编码等编码样式。例如,如果C#代码库具有缩进使用五个空格字符、文档使用UTF-8编码,并且行以CR/LF结尾的约定,则可以将EditorCon......