uni-app实现多图上传案例
.content {
text-align: center;
height: 400upx;
margin-top: 200upx;
}
.pop_ty {
display: flex;
justify-content: center;
height: 50px;
align-items: center;
padding-top: 15upx;
font-size: 15px;
color: #007AFF;
border-bottom-color: #C0C0C0;
border-bottom-width: 2upx;
border-bottom-style: solid;
}
.top_nav {
display: flex;
flex-direction: row;
margin-top: 30px;
justify-content: space-between;
align-items: center;
border-bottom-color: #EEEEEE;
color: #007AFF;
font-size: 20upx;
border-bottom-style: solid;
padding-bottom: 2upx;
border-bottom-width: 2upx;
margin-bottom: 5upx;
}
.nav_left {
padding-left: 5upx;
}
.nav_mid {
font-size: 40upx;
color: #c0c0c0;
}
.nav_right {
padding-right: 20upx;
}
.nav_right>.icon-xiangji {
font-size: 50upx;
color: #333333;
}
效果图:
后端(PHP)
if(!empty($_FILES)){
//获取扩展名
// $exename = getExeName($_FILES['images1']);
$file = json_decode($_FILES);
for ($i=0; $i < count($_FILES) ; $i++) {
$fileName[] = 'images'.$i;
}
$final = array();
foreach ($fileName as $k => $v) {
$exename = $_FILES[$v]['type'];
if($exename != 'image/png' && $exename != 'image/jpg' && $exename != 'image/gif' && $exename !='image/jpeg') {
exit('不允许的扩展名');
}
//此处地址根据项目而定,唯一注意的就是图片命名,这里难得去获取后缀,随便写了个png
$imageSavePath =WEB_CORE_LIB.'images'.'/'.uniqid().rand(1,100).'.png';
if(move_uploaded_file($_FILES[$v]['tmp_name'],$imageSavePath)){
$final[] = $v;
}
}
echo json_encode($final);
}else{
echo 2;
}
本项目为后端进行图片批量处理,当然也可以在前端循环调用uni.uploadFile。其余待补充
原文链接:https://blog.csdn.net/weixin_44416446/article/details/99573283
页面更新:2024-04-27
本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828
© CopyRight 2008-2024 All Rights Reserved. Powered By bs178.com 闽ICP备11008920号-3
闽公网安备35020302034844号