Giter VIP home page Giter VIP logo

jquery.compressupload.js's Introduction

demo: <!doctype html>

<title>www.imwinlion.com压缩上传解决方案</title> <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script src="jquery.compressupload.js"></script>

<script> function onpickup(e){ console.log("onpickup",e) $("#prev").attr("src",e.target.result) } $(function(){
    $("#filedom").compressandupload({
        onpickup:onpickup,
        "maxWidth":200,
        maxHeight:200,
        quality:0.1,
        serveurl:"/attach/upload"
        }).then(
            function(result){
           console.log("result",result)
         })

})
</script>

参数说明 /*

  • maxWidth:int,压缩后图片的最大宽度,默认400
  • maxHeight:int,压缩后图片的最大高度,默认400
  • quality:float,压缩图片质量,0-1之间小数,默认0.92
  • serveurl:string,后端处理上传的连接地址,
  • minSize:int,小于这个大小的文件都不压缩,
  • onpickup:function,当文件选中即进行的回调,我们一般使用 e.target.result
  • 这是该文件的base64编码,
  • 类似于这样,data:image/png;base64,iVBORw0
  • 我们可以使用用来做预览,
  • postarg:{}//用户自定义的上传参数,如用户id等
  • base64key:string,后端接收base64文件编码参数的名字,默认为base64data
  • @result:该函数封装了jquery 的promis 对象,因此采用then的方式,无返回

**/

jquery.compressupload.js's People

Contributors

techidea8 avatar betaniao avatar

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.