npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

simple-uploader-zjz

v2.0.8

Published

based on [email protected]

Downloads

3

Readme

simple-uploader

一个不带UI的HTML5上传组件,为实现各种上传交互提供最大的灵活度。

依赖项:

浏览器支持:IE10+、Chrome、Safari、Firefox。

###使用方法

首先在页面里引用相关脚本:

<script type="text/javascript" src="path/to/jquery.min.js"></script>
<script type="text/javascript" src="path/to/module.js"></script>
<script type="text/javascript" src="path/to/uploader.js"></script>

初始化uploader实例:

var uploader = simple.uploader({
    url: '/upload'
});

获取文件对象,然后通过uploader上传:

$('#select-file').on('change', function(e) {
    uploader.upload(this.files);
});

###API文档

####初始化选项

url

上传接口地址,必选。

params

hash对象,上传请求附带的参数,可选

fileKey

服务器端获取上传文件的key,可选,默认是'upload_file'

connectionCount

允许同时上传的文件数量,可选,默认值是3

####方法

uploader实例会暴露一些公共方法:

upload ([File Object]/[Input Element]/[File Array])

开始上传的接口,可以接受的参数有:File对象(通过input:file选择或者通过拖拽接口获取)、input:file元素或者File对象的数组。

cancel (file/fileId)

取消上传某个文件,可以接受事件传出来的file对象或者file的id。

destroy

摧毁uploader实例

readImageFile ([File Object], callback)

通过图片的File对象获取图片的base64预览图,在上传图片之前需要预览的时候非常有用。

####事件

uploader实例可以绑定一些自定义事件,例如:

uploader.on('beforeupload', function(e, file) {
  // do something before upload
});

beforeupload (e, file)

上传开始之前触发,return false可以取消上传

uploadprogress (e, file, loaded, total)

上传的过程中会触发多次,loaded是已经上传的大小,total是文件的总大小,但是是byte。

uploadsuccess (e, file, result)

上传成功的时候触发,result是服务器端返回的json响应。

uploaderror (e, file, xhr, status)

上传失败的时候触发,xhr是上传接口的XMLHttpRequest对象,status是报错信息。

uploadcomplete (e, file, responseText)

无论上传成功还是失败都会触发这个事件,responseText是响应的文本字符串。

uploadcancel (e, file)

调用uploader.cancel()方法取消上传的时候会触发这个事件