Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
file-dropzone
Advanced tools
A simple lightweight file dropzone component based on jQuery. You can easily make any existing element become a dropzone that holds files.
var myDropzone = new FileDropzone({
target: '#box',
fileHoverClass: 'entered',
clickable: true,
multiple: true,
forceReplace: false,
paramName: 'my-file',
accept: '',
onChange: function () {
var files = this.getFiles()
var elem = this.element
elem.empty()
files.forEach(function (item) {
elem.append('<div class="file-name">' + item.name + '</div>')
})
},
onEnter: function () {
console.log('enter')
},
onLeave: function () {
console.log('leave')
},
onHover: function () {
console.log('hover')
},
onDrop: function () {
console.log('drop')
},
onInvalid: function (files) {
console.log('file invalid')
console.log(files)
},
beforeAdd: function () {
return true
}
})
// method 1
var options = {}
new FileDropzone($('#container'), options)
// method 2
var options = { target: '#container' }
new FileDropzone(options)
option | type | explain | default |
---|---|---|---|
target | string | css selector string. specifies which element you want to be a dropzone | |
fileHoverClass | string | class name that will be added to target element when file dragged over it | 'dropzone--file-hover' |
clickable | boolean | whether the file choosing window will pop up when target element is clicked | true |
multiple | boolean | whether the dropzone can hold multiple files | true |
noFolder | boolean | whether to filter out folders when dropping | true |
unique | boolean | whether to ignore duplicate files when adding | false |
forceReplace | boolean | whether to replace the existing file list when adding. If set to false , new files will append to the list | false |
accept | string | mimetype or file extensions separated by comma to specify a certain types of files the dropzone accepts | |
capture | boolean | same as input[type=file] element's capture attribute | true |
paramName | string | same as input[type=file] element's name attribute | 'file' |
onChange | function | called when file list length changed | |
onEnter | function | called when file dragged enters the target element. accepts 1 argument which is native dragenter event object. | |
onLeave | function | called when file dragged leaves the target element. accepts 1 argument which is native dragleave event object. | |
onHover | function | called when file dragged moves on the target element. accepts 1 argument which is native dragover event object. | |
onDrop | function | called when file dropped into to target element. accepts 1 argument which is native drop event object. | |
onFolderFound | function | called when on or more folders found among the files user chooses. accepts 1 argument which is an array of the folders (they are also File objects). | |
onInvalid | function | called when invalid type files found among the files user chooses. accepts 1 argument which is an array of the spotted invalid files. | |
beforeAdd | function | called right before adding new files to the list. accepts 1 argument which is an array of the valid files that are about to be added to the list. If the function return false , the adding action will be stopped. |
foo
: (File object or Number) if foo
is a file which is already in the file list, it will be removed from the list. If foo
is a number, the number indicates the index of file that will be removed.null
.null
if the list is empty.null
if the list is empty.disable()
.disableClick()
.static
getFileSize(file, unit)file
: (File object) the file whose size you want to get.unit
: specifies the unit. It should be one of these: b, kb, mb, gb, tb.FileDropzone
constructor.var file = myDropzone.getFiles()[0]
var size = FileDropzone.getFileSize(file, 'mb')
FAQs
Drop files anywhere on your web page. Based on jQuery.
The npm package file-dropzone receives a total of 30 weekly downloads. As such, file-dropzone popularity was classified as not popular.
We found that file-dropzone demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.