惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
小众软件
小众软件
博客园 - 叶小钗
宝玉的分享
宝玉的分享
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
SegmentFault 最新的问题
B
Blog RSS Feed
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
Google DeepMind News
Google DeepMind News
U
Unit 42
F
Fortinet All Blogs
IT之家
IT之家
Y
Y Combinator Blog
Martin Fowler
Martin Fowler
T
The Blog of Author Tim Ferriss
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
Stack Overflow Blog
Stack Overflow Blog
Blog — PlanetScale
Blog — PlanetScale
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - 小馬過河﹎

一些有用的javascript函数 layui多文件上传表格 layui静态表格防止被内容撑开变形 php使用mysql-text字段存取json字符串 ThinkPHP3 系统常量__SELF__在生产模式(debug=false)下不更新 PHP将数据表里的两个字段映射成对象的键和值 普通表格table样式美化 PHP通用请求函数sendCurl 查看证书/apk指纹md5/sha1/sha256 php跨域 javascript使用正则表达式高亮关键字 博文阅读密码验证 - 博客园 [转载]php递归生成树形结构(几种常见的数据结构) PHP二维数组排序|PHP二维数组去重 textarea中禁止使用换行(回车) php json_encode 斜杠 反斜杠 转义处理 ThinkPHP获取当前url js获取url中的查询参数 ThinkPHP接收header自定义参数
layui多图片上传
小馬過河﹎ · 2023-02-18 · via 博客园 - 小馬過河﹎
<div>
	<button type="button" class="layui-btn" id="mulUpload">图片上传</button>
	<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
		预览图:
		<div class="layui-upload-list" id="mulPreview"></div>
	</blockquote>
</div>

<link rel="stylesheet" href="/Public/viewer/viewer.min.css">
<script src="/Public/viewer/viewer.min.js"></script>

<script>
	var mul_imgs = ['http://i.srsr.cc/uploads/info/23021810323430.jpg', 'http://i.srsr.cc/uploads/info/23021810324186.jpg', 'http://i.srsr.cc/uploads/info/23021810324430.jpg', 'http://i.srsr.cc/uploads/info/23021810325261.jpg']

	function showImgs() {
		$('#mulPreview').empty()
		mul_imgs.forEach((img, index) => {
			$('#mulPreview').append(`
					<div style="background:url(${img}) center center no-repeat;">
						<img src="${img}" alt="图${index + 1}" />
						<i class="layui-icon layui-icon-close-fill" onclick="delImg(${index})"></i>
					</div>
				`)
			$('#mulPreview').viewer('update')
		})
	}

	function delImg(index) {
		mul_imgs.splice(index, 1)
		showImgs()
	}

	showImgs()

	layui.use(['upload', 'layer', 'form'], function () {
		let upload = layui.upload
		let layer = layui.layer
		let form = layui.form

		upload.render({
			elem: '#mulUpload'
			, url: '__CONTROLLER__/uploadImg' //此处配置你自己的上传接口即可
			, multiple: true
			, data: { path: '/info/' }
			, before: function (obj) {
				layer.load()
			}
			, done: function (res) {
				mul_imgs.push(res.data.fullSrc)
				console.log('mul_imgs', mul_imgs)
			}
			, allDone: function (res) {
				layer.closeAll('loading')
				showImgs()
			}
		})

	})
</script>

<style>
	#mulPreview {
		display: flex;
		flex-wrap: wrap;
	}

	#mulPreview div {
		margin: 0 16px 16px 0;
		position: relative;
		width: 150px;
		height: 150px;
		box-shadow: 0 2px 5px 1px #555;
		border-radius: 4px;
		background-size: cover !important;
	}

	#mulPreview div img {
		width: 100%;
		height: 100%;
		opacity: 0;
	}

	#mulPreview div i {
		position: absolute;
		top: -5px;
		right: 5px;
		font-size: 30px;
		color: red;
		opacity: 0.6;
	}
</style>