当前位置:首页 > 未分类

PbootCMS上传文件,保存原有的文件名

admin4年前 (2023-03-15)未分类951

方法:以单页为例,
        1. 在数据库表ay_content添加enclosure_name字段;
        2. apps\admin\view\default\content\single.html
            在附件一项中,隐藏原有enclosure的input(注意是隐藏,不是删除),增加enclosure_name的input。
        3. apps\admin\view\default\js\mylayui.js
            在附件上传实例部分,增加choose方法,从choose方法的obj中获取到文件名,赋值到enclosure_name的input。
            ,choose: function(obj){ 
                console.log(obj)
                let item = this.item;
                  let des=$(item).data('des');
                  obj.preview(function (index, file, result) {
                    // console.log(index); //得到文件索引
                    // console.log(file.name); //得到文件对象
                    $('#'+des+"_name").val(file.name); 
                });
            }
        4. apps\admin\controller\content\SingleController.php
        mod方法中,在增加/修改的部分增加变量enclosure_name的保存。

扫描二维码推送至手机访问。

版权声明:本文由web开发技术分享发布,如需转载请注明出处。

本文链接:https://www.htmlcmf.cn/?id=3

分享给朋友:

相关文章

jquery的ajax设置为同步

jquery的ajax设置为同步在使用$.get或者$.post的时候,前面加上$.ajaxSettings.async = false;使用完之后再设置为异步$.ajaxSettings.async = true; 而在使用$.…

CSS:实现background-image背景图片全屏铺满自适应

body {     /* 加载背景图 */     background-image: url(images/bg…

css文字颜色渐变

background-size: 100%; background-repeat: repeat; background-clip: text; -webkit-background-clip: …

Js生成随机数/随机字符串的5种方法

Js生成随机数/随机字符串的5种方法:方法1:使用randomStringfunction randomString(e) {   e = e || 8;&n…

nginx 设置某个目录只允许访问指定后缀文件

server {        listen 80;        server_name your…