GithubHelp home page GithubHelp logo

cupload's Introduction

cupload

基于原生js的图片上传插件

支持多图上传、选择预览、数量限制、像素限制、大小限制、图片删除、放大预览、图片排序、异步上传、编辑初始化图片

下载使用

下载:

git clone https://github.com/cuuuuuirz/cupload.git

使用:

引入js:

<script src="static/js/cupload.js"></script>

在需要的位置添加html:

<div id="cupload"></div>

实例化cupload对象:

<script type="text/javascript">
	var cupload = new Cupload ({
		ele: "#cupload"
	});
</script>

可选参数

//为方便比较和计算,部分参数为number型,已设置默认单位,不可再带单位。

{
	ele             : "#cupload",           // 实例化的DOM对象,必需
	name            : "image",              // 图片input的name名,非必需,默认为image
	num             : 1,                    // 可上传图片的数量,非必需,默认为1
	url             : "./upload.php",       // 异步上传url,非必需,无默认值
	deleteUrl       : "./delete.php",       // 异步删除url,删除时同时删除服务器图片,非必需,无默认值
	width           : 148,                  // 预览框的宽,单位为px,非必需,默认为148
	height          : 148,                  // 预览框的高,单位为px,非必需,默认为148
	minSize         : 1024,                 // 图片大小最小限制,单位为KB,非必需,无默认值
	maxSize         : 2048,                 // 图片大小最大限制,单位为KB,非必需,无默认值
	limitedSize     : 2048,                 // 图片大小要求,单位为KB,非必需,无默认值
	minWidth        : 100,                  // 图片宽度最小限制,单位为px,非必需,无默认值
	minHeight       : 100,                  // 图片高度最小限制,单位为px,非必需,无默认值
	maxWidth        : 2000,                 // 图片宽度最大限制,单位为px,非必需,无默认值
	maxHeight       : 2000,                 // 图片高度最大限制,单位为px,非必需,无默认值
	limitedWidth    : 800,                  // 图片宽度要求,单位为px,非必需,无默认值
	limitedHeight   : 800,                  // 图片高度要求,单位为px,非必需,无默认值
	data            : ["1.png", "2.jpg"],   // 编辑模式下初始显示的图片路径,非必需,无默认值
}

cupload's People

Stargazers

 avatar  avatar  avatar  avatar Kane Young avatar Noah丶 avatar Ayden avatar Rucheng Tang avatar  avatar  avatar  avatar  avatar  avatar 木鱼 avatar 蜡笔小鑫 avatar  avatar Yunlong Zhou avatar 沐雪 avatar zuohuaijun avatar  avatar LuFei avatar link avatar baijunyao avatar Dami avatar

Watchers

崔荣志 avatar

cupload's Issues

请问怎么支持图片批量删除

您好,我现在有个需求:
一个选择框,选了是的时候显示图片上传框
当选了否的时候,需要把已经选上的图片一次性清除掉
请问这个插件可以实现嘛?
如果可以实现的话,怎么实现呢
先谢谢您~

一次性上传多张图片,取到的名称有问题。

for (j = 0; j < this.uploadInput.files.length; j++) { var file = this.uploadInput.files[j] if (!file || this.limitedSize(file)) { this.createUploadBox() return false } var reader = new FileReader() var _this = this reader.filename = file.name; reader.onload = function (e) { _this.limitedWidthAndHeight(e.target.result, e.target.filename) } reader.readAsDataURL(file); }
用 reader.filename=file.name作为临时变量存储,然后再reader.onload里用e.target.filename读取。就可以了。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.