UNPKG

js-upload-image

Version:

This is a npm package for mobile uploading pictures.

26 lines (25 loc) 1.31 kB
#js-upload-image > [Chinese documents](https://github.com/lixilin123/upload-image/blob/master/README-zh.md) ### 1.Introduction This is a github repository with an object for mobile upload images. ### 2.Usage 1.Installation - Method 1: Use the ***npm*** command to install, ***npm install --save js-upload-image***. - Method 2: Copy the contents of the ***upload-image.js*** file in the root directory to the js file you created yourself. 2.Import - Import using ES6: ***import uploadImg from 'js-upload-image'*** (You can choose the name according to your preferences when importing, temporarily use ***uploadImg***). ### 3.API The calling method and parameters are described as follows: ```javascript uploadImg.start({ event:event, // event object in the onchange event of input url:'', // The address to upload params:{}, // Uploads the carried parameter callback:(res)=>{}, // The uploaded callback function dataType:'', // The result data type, default 'json' withCredentials:false, // whether the request carries a cookie, the default is not imgMaxSize:1024 * 1024 * 10, // Maximum size allowed for image upload, default 10M imgShouldCompressSize:1024 * 200 // When the image size is greater than imgShouldCompressSize to compress, default 200k }) ```