Allow multiple files to be uploaded at once

fixes vector-im/vector-web#219
pull/21833/head
Aviral Dasgupta 2016-04-03 01:26:50 +05:30
parent 25b35a09b9
commit 0eeaac88b4
1 changed files with 5 additions and 2 deletions

View File

@ -48,8 +48,10 @@ module.exports = React.createClass({
onUploadFileSelected: function(ev) { onUploadFileSelected: function(ev) {
var files = ev.target.files; var files = ev.target.files;
// MessageComposer shouldn't have to rely on its parent passing in a callback to upload a file // MessageComposer shouldn't have to rely on its parent passing in a callback to upload a file
if (files && files.length > 0) { if (files) {
this.props.uploadFile(files[0]); for(var i=0; i<files.length; i++) {
this.props.uploadFile(files[i]);
}
} }
this.refs.uploadInput.value = null; this.refs.uploadInput.value = null;
}, },
@ -130,6 +132,7 @@ module.exports = React.createClass({
<TintableSvg src="img/upload.svg" width="19" height="24"/> <TintableSvg src="img/upload.svg" width="19" height="24"/>
<input ref="uploadInput" type="file" <input ref="uploadInput" type="file"
style={uploadInputStyle} style={uploadInputStyle}
multiple
onChange={this.onUploadFileSelected} /> onChange={this.onUploadFileSelected} />
</div> </div>
); );