我有文件上传输入:
<input onChange={this.getFile} id="fileUpload" type="file" className="upload"/>
我是这样处理上传的:
getFile(e) {
e.preventDefault();
let reader = new FileReader();
let file = e.target.files[0];
reader.onloadend = (theFile) => {
var data = {
blob: theFile.target.result, name: file.name,
visitorId: this.props.socketio.visitorId
};
console.log(this.props.socketio);
this.props.socketio.emit('file-upload', data);
};
reader.readAsDataURL(file);
}
如果我上传同一个文件两次,则不会触发上载事件.我该怎么解决?对于简单的js代码来说,做以下事情就足够了:这个.值=空;在change handler中.我怎么能用ReactJS做呢?