Skip to content

Commit

Permalink
Fixed #395
Browse files Browse the repository at this point in the history
  • Loading branch information
Merve7 committed Apr 30, 2018
1 parent 2ffc5bb commit 02cc4af
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/components/fileupload/FileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,25 @@ export class FileUpload extends Component {

onFileSelect(event) {
this.setState({msgs:[]});
this.files = [];
let files = event.dataTransfer ? event.dataTransfer.files : event.target.files;
for (let file of files) {
if (!this.isFileSelected(file)) {
if (this.validate(file)) {
if (this.isImage(file)) {
file.objectURL = window.URL.createObjectURL(file);
}

this.setState({files: [...this.state.files, file]}, () => {
if (this.hasFiles() && this.props.auto) {
this.upload();
}
});
this.files.push(file);
}
}
}


this.setState({files: this.files}, () => {
if (this.hasFiles() && this.props.auto) {
this.upload();
}
});

if(this.props.onSelect) {
this.props.onSelect({originalEvent: event, files: files});
}
Expand Down Expand Up @@ -370,7 +372,7 @@ export class FileUpload extends Component {
);
}

render() {
render() {
if (this.props.mode === 'advanced')
return this.renderAdvanced();
else if (this.props.mode === 'basic')
Expand Down

0 comments on commit 02cc4af

Please sign in to comment.