Coder Social home page Coder Social logo

hackxiu / up Goto Github PK

View Code? Open in Web Editor NEW

This project forked from itorr/up

0.0 1.0 0.0 10 KB

偷揉图床 JavaScript API - 免费可外链的图片上传服务

Home Page: http://x.mouto.org/wb

License: Apache License 2.0

JavaScript 90.11% HTML 9.89%

up's Introduction

#偷揉图床 API 说明 文档

偷揉图床 API

偷揉图床是一个简单的图片分享工具 http://x.mouto.org/wb

全部功能包括:

  1. 选图->返回地址

因偷揉相册难产、但图床需求迫切,所以提前把上一个版本的公开 API 整理成文档。

JavaScript API

###上传

引入 up.itorr.js

<script src="up.itorr.js"></script>

或者引用 线上版本的 up.itorr.js

<script src="http://x.mouto.org/wb/up.itorr.js"></script>

使用这个版本的地址时,会在上传服务出现问题时提供备选方案支持 ####第一种使用方式

UP=function( !图片文件 , !正确回调 , ?错误回调 , ?进度回调 )
/**
 * !感叹号 必须存在
 * ?疑问号 可选
**/

#####第一种使用方式的例子

UP(图片文件,function(pid){  //图片 pid 部分
	console.log(/上传成功,图片地址:/,'http://ww2.sinaimg.cn/large/'+pid)
},function(error){ //错误回调,返回错误原因文本
	console.log(/上传文件出错了!/,error)
},function(进度){ //进度回调,返回进度 0-1
	console.log(/进度/,进度*100+'%')
})

####第二种使用方式

UP=function({
	file: !图片文件 ,
	success: !正确回调 ,
	error: ?错误回调 ,
	upload: ?进度回调 
})
/**
 * !感叹号 必须存在
 * ?疑问号 可选
**/

#####第二种使用方式的例子

UP({
	file:图片文件,
	success:function(pid){  //正确回调,返回图片 pid 部分文本
		console.log(/上传成功,图片地址:/,'http://ww2.sinaimg.cn/large/'+pid)
	},error:function(error){ //错误回调,返回错误原因文本
		console.log(/上传文件出错了!/,error)
	},upload:function(进度){ //进度回调,返回进度 0-1
		console.log(/进度/,进度*100+'%')
	}
})

###演示地址

http://x.mouto.org/wb/上传演示.html

up's People

Contributors

itorr avatar

Watchers

 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.