Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wewoor/h5uploader
This is a simple file upload plugin depends on HTML5. You can use it to mordern browser.
https://github.com/wewoor/h5uploader
html5 javascript mordern-browser uploader
Last synced: 3 months ago
JSON representation
This is a simple file upload plugin depends on HTML5. You can use it to mordern browser.
- Host: GitHub
- URL: https://github.com/wewoor/h5uploader
- Owner: wewoor
- Created: 2015-05-06T15:00:10.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-05-25T03:08:25.000Z (over 4 years ago)
- Last Synced: 2024-10-14T22:44:23.987Z (3 months ago)
- Topics: html5, javascript, mordern-browser, uploader
- Language: JavaScript
- Size: 10.1 MB
- Stars: 47
- Watchers: 4
- Forks: 28
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HTML5 file uploader
This is a simple file upload plugin depends on HTML5. You can use it to mordern browser.
## Install
install by bower:
```
bower install h5uploader --save
```
or:```
git clone https://github.com/wewoor/h5uploader.git
```## Example
Import this script in you html page:
```html
```
### html
```html
Upload
```### Javascript
```javascript
var uploader = document.getElementById('uploader');
uploader.addEventListener("click", function(e) {H5Uploader.upload({
action: 'upload',
id: 'myfile',
size: {
max: 5000, // 5000kb
valide: function(e) {
if (e) {
alert("The size of " + e.name + " is exceed max value!");
}
}
}, // MB
type: {
name: 'csv;png;jpg',
valide: function(e) {
if (e) {
alert("The type of " + e.name + " is not supported!");
}
}
},
progress: function() {
var p = document.createElement('p');
p.innerHTML = "uploading";
p.id = "loading";
document.body.appendChild(p);
},
success: function(data) {
alert(data);
if (data && data == 200) {
document.getElementById('loading').innerHTML = "The file upload successfully!";
alert("The file upload successfully.");
}
},
fail: function(data) {}
});}, false);
```**more examples and demos can be found in [`/example`](https://github.com/wewoor/h5uploader/tree/master/example) directory.**
## Options
name | type | description
| - | - | - |
action | string | file upload request path
id | string | input element id,`example: `
size | object | validate file size
type | object | validate file type
progress | function | progress for upload
success | function | when file upload successfully callback
fail | function | when file upload fail callback## License
MIT