Giter Club home page Giter Club logo

benupload's Introduction

BenUpload

  • pc、h5 上传图片插件,依赖 Jquery,或 Zepto
  • 目前功能:
    • 1.可上传到服务器
    • 2.压缩图片
    • 3.生成 base64

用法

  • 1.用的时候,请先引入 JQuery 或者 Zepto
<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
  • 2.引入 BenUpload.js
<script type="text/javascript" src="js/BenUpload.js"></script>

<script type="text/javascript" src="dist/BenUpload.min.js"></script>
  • 3.使用
BenUploadUtils({
  dom: ".uploadfile", // 需要挂在的DOM
  url: "/", // 上传的服务器地址
  isCompress: true, // 是否进行压缩
  limitSize: 10240000, // 1024000kb
  limitFormat: "gif,jpg,jpeg,png,GIF,JPG,PNG", // 使用什么格式
  limitSizeCallback: function (err) {
    // 限制大小的回调事件
    console.log(err);
  },
  limitFormatCallback: function (err) {
    // 限制格式的回调事件
    console.log(err);
  },
  onUploadBeforeCallback: function (res) {
    // 上传图片之前的回调事件
    console.log(res);
  },
  onUploadSuccessCallback: function (res) {
    // 上传成功的回调事件
    console.log(res);
  },
  onUploadFailCallback: function (res) {
    // 上传失败的回调事件
    console.log(res);
  },
  onUploadAlwaysCallback: function (res) {
    // 上传无论什么结果的回调事件
    console.log(res);
  },
  onRenderResizerBefore: function (res) {
    // 压缩之前的回调事件
    $("#preview").attr("src", res);
  },
  onRenderResizerAfter: function (res) {
    // 压缩之后的回调事件
    $("#nextview").attr("src", res);
  },
}).init();

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.