
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
file-button
Advanced tools
var filebutton = require('file-button');
var request = require('superagent');
filebutton
.create()
.on('fileinput', function(fileinput){
var req = request.post('/upload/')
var files = fileinput.files;
var file;
for(var i = 0, len = files.length; i < len; ++i){
var file = files[i];
req.attach('ajaxfile-' + i, file, file.name);
}
req
.on('progress', function(e){
if (e.lengthComputable) {
// handle progress bar here
}
})
.end(function(err, res) {
if (res.ok) {
// handle successful result here
}
});
})
.mount(document.getElementById('button'));
<a id="button" >Upload</a>
or
<div id = "button">Upload</div>
or
<button id="button">Upload</button> // IE8 won't work
$ npm test
var filebutton = require('file-button');
filebutton
.create() // create the instance
.on('fileinput', listener) // listen to the event `fileinput`
.mount(el); // mount the view on the button
A file-button
can be initiated by invoking the .create()
method. For example.
var filebutton = require('file-button');
filebutton.create();
The file-button
instance is also an Event-Emitter using component-emitter.
options : {Object}
Emitted each time the file input value is changed. The fileinput
element will be removed from the DOM Tree and emitted to the listener.
Emitted after the instance is destroyed.
Mount the view on an element. For example, a bootstrap button
<a class="btn btn-lg btn-primary">Upload</a>
Enable the file input button.
Disable the file input button.
Destroy the file input button. A destroyed
event will be emitted.
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.