# jQuery file upload
<input type="file" name="my-file" id="my-file" />
$('#my-file').upload('/upload/');
// OR
$('#my-file').upload('/upload/', function(fd) {
fd.append('myparam1', '1');
fd.append('myparam2', '2');
});
<div id="dragdrop">
<br />
<br />
<br />
<br />
Drag & Drop files
<br />
<br />
<br />
<br />
</div>
$('#dragdrop').dragdrop('/upload/', 'css-class-dragover');
// OR
$('#dragdrop').dragdrop('/upload/', 'css-class-dragover', function(fd) {
fd.append('myparam1', '1');
fd.append('myparam2', '2');
});
On begin upload.
$('#my-file,#dragdrop').on('upload-begin', function(e) {
// your code here
});
On end upload.
$('#my-file,#dragdrop').on('upload-end', function(e, isUploaded, data) {
if (data === null) {
// error
return;
}
// your code here
});
On upload error.
$('#my-file,#dragdrop').on('upload-error', function(e, err, status) {
// your code here
console.log(err, status);
});
On upload progress.
$('#my-file,#dragdrop').on('upload-progress', function(e, percentage, transferSpeed, timeRemaining) {
// your code here
});