file 自定义上传附件并展示缩略图

<div id="picInputDiv" style="display: none;"></div>
var newInput = $(this).clone();
newInput.attr("id","newInput"+(picFileLen-1)); // picFileLen 是个变量。所以每次拿到的 input id 唯一,避免冲突
$("#picInputDiv").append(newInput);
// picInputDiv index>picIndex 角标依次 -1;
var inputLen = $("#picInputDiv").children().length;
var Dvalue = inputLen-1-parIndex;
if(Dvalue ==0) {
$("#picInputDiv").find("#newInput"+parIndex).remove();
} else if(Dvalue > 0) {
$("#picInputDiv").find("#newInput"+parIndex).remove();
for(var i=1; i<Dvalue+1; i++){
$("#newInput"+(parIndex+i)).attr("id","newInput"+(parIndex+i-1));
}
}
- 样式不OK,
- 只能显示附件名称
- 不能显示附件缩略图
- 只能保留最后一次的上传结果,不能实现多个上传
// 监测是否超出限制
function checkLen(len,max){
if(len<max){
return true;
} else {
layer.msg("不能再上传了。已经满额 ");
return false;
}
}
/*
点击上传附件
*/
.btn-add-div {
width: 150px;
height: 150px;
position: relative;
margin-right: 10px;
display: inline-block;
}
#picShowDiv {
display: inline-block;
}
.btn-add {
position: absolute;
display: block;
width: 100%;
height: 100%;
opacity: 1;
border: 1px dashed #ccc;
border-radius: 5px;
background: #fff;
outline: none;
}
.btn-add:before {
content: '';
position: absolute;
width: 32px;
height: 2px;
left: 50%;
top: 50%;
margin-left: -16px;
margin-top: -1px;
background: #aaa;
}
.btn-add:after {
content: '';
position: absolute;
width: 2px;
height: 32px;
left: 50%;
top: 50%;
margin-left: -1px;
margin-top: -16px;
background: #aaa;
}
.btn-add-file {
position: absolute;
display: block;
width: 100% !important;
height: 100%;
opacity: 0;
}
.btn-add-div:hover {
cursor: pointer;
}
/* 缩略图 */
.pic-thumbnail {
width: 150px;
height: 150px;
box-sizing: border-box;
padding: 10px;
overflow: hidden;
display: inline-block;
border: 1px dashed #ccc;
background: #fff;
position: relative;
border-radius: 5px;
margin-right: 10px;
}
/* 删除 */
.delete-content {
display: inline-block;
position: absolute;
right: 10px;
top: 10px;
width: 20px;
height:20px;
border-radius: 50%;
background: #555;
border: none;
z-index: 10;
}
.delete-content:before {
display: inline-block;
content: '';
position: absolute;
width: 8px;
height: 8px;
left: 6px;
top: 2px;
border-width: 0 2px 2px 0;
border-style: solid;
border-color: #fff;
transform: rotate(45deg);
}
.delete-content:after {
display: inline-block;
content: '';
position: absolute;
width: 8px;
height: 8px;
left: 6px;
top: 10px;
border-width: 0 2px 2px 0;
border-style: solid;
border-color: #fff;
transform: rotate(-135deg);
}
.delete-content:hover {
cursor: pointer;
opacity: .7;
}
file 自定义上传附件并展示缩略图的更多相关文章
- Dynamics CRM 自定义上传附件的图片悬浮层显示
CRM中的附件是以流的形式保存在了数据库中,这样做的一个坏处是一旦系统运行时间久,附件上传的多了势必会导致数据库极速扩大,即影响系统的运行效率也对后期的迁移维护带来了不必要的麻烦.所以很多的客户都会要 ...
- salesforce零基础学习(八十九)使用 input type=file 以及RemoteAction方式上传附件
在classic环境中,salesforce提供了<apex:inputFile>标签用来实现附件的上传以及内容获取.salesforce 零基础学习(二十四)解析csv格式内容中有类似的 ...
- java上传附件,批量下载附件(一)
上传附件代码:借助commons-fileupload-1.2.jar package com.str; import java.io.BufferedInputStream;import java. ...
- AntD框架的upload组件上传图片时使用customRequest方法自定义上传行为
本次做后台管理系统,采用的是 AntD 框架.涉及到图片的上传,用的是AntD的 upload 组件. 我在上一篇文章<AntD框架的upload组件上传图片时使用customRequest方法 ...
- React项目中使用wangeditor以及扩展上传附件菜单
在最近的工作中需要用到富文本编辑器,结合项目的UI样式以及业务需求,选择了wangEditor.另外在使用的过程中发现wangEditor只有上传图片和视频的功能,没有上传文本附件的功能,所以需要对其 ...
- jquery 通过ajax FormData 对象上传附件
之前上传附件都是用插件,或者用form表单体检(这个是很久以前的方式了),今天突发奇想,自己来实现附件上传,具体实现如下 html: <div> 流程图: <input id=& ...
- Discuz模拟批量上传附件发帖
简介 对于很多用discuz做资源下载站来说,一个个上传附件,发帖是很繁琐的过程.如果需要批量上传附件发帖,就需要去模拟discuz 上传附件的流程. 模拟上传 discuz 附件逻辑 dz附件储存在 ...
- input file 图片上传
使用第三方:jquery.ajaxfileupload.jsinput中的name根据后端来定 <form method="post" enctype="multi ...
- Dynamic CRM 2013学习笔记(十三)附件上传 / 上传附件
上传附件可能是CRM里比较常用的一个需求了,本文将介绍如何在CRM里实现附件的上传.显示及下载.包括以下几个步骤: 附件上传的web页面 附件显示及下载的附件实体 调用上传web页面的JS文件 实体上 ...
随机推荐
- Windows服务的安装卸载及错误查找
@echo off echo 清理原有服务项. . . %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil /U D:\abc\te ...
- TiDB 架构及设计实现
一. TiDB的核心特性 高度兼容 MySQL 大多数情况下,无需修改代码即可从 MySQL 轻松迁移至 TiDB,分库分表后的 MySQL 集群亦可通过 TiDB 工具进行实时迁移. 水平弹性扩展 ...
- Swift中 删除Array的元素对象
Swift中Array的删除对象 在Swift中数组Array没有removeObject的方法 1.找到下标 let model_index = selectedArray.index(where: ...
- NTFS权限和共享权限的区别
共享权限 共享权限有三种:完全控制.更改.读取 共持本地安全性.换句话说,他在同一台计算机上以不同用户名登录,对硬盘上同一文件夹可以有不同的访问权限. 注意:NTFS权限对从网络访问和本机登录的用户都 ...
- maven中央仓库、远程仓库地址
1.http://repo1.maven.org/maven2 (官方,速度一般) 2.http://maven.aliyun.com/nexus/content/repositories/centr ...
- 任意N个不同数的逆序对平均值
在学习数据结构的时候看到了以下定理: 但是老师并没有解释,本着钻研的精神决定搞清楚为什么是这个数. 在百度 google一番之后并没有找到,决定自己试着证明. 最开始走了一些弯路,但突然灵光一闪很容易 ...
- ASP.NET MVC 下自定义模型绑定,去除字符串类型前后的空格
直接贴代码了: SkyModelBinder.cs using System.ComponentModel; using System.Linq; using System.Web.Mvc; name ...
- pytorch中文文档-torch.nn常用函数-待添加-明天继续
https://pytorch.org/docs/stable/nn.html 1)卷积层 class torch.nn.Conv2d(in_channels, out_channels, kerne ...
- 彻底搞懂spark的shuffle过程(shuffle write)
什么时候需要 shuffle writer 假如我们有个 spark job 依赖关系如下 我们抽象出来其中的rdd和依赖关系: E <-------n------, ...
- antd pro 分支
添加图片 这两种都可以 form表单问题 1 @Form.create() 这是绑定表单和组件,必须有,这样就能从this.props 中找到Form了 2 Select 要写initialValue ...