diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-06-29 04:03:58 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-06-29 04:03:58 +0200 |
| commit | a7465a66cd49a943b725f0a3ef45d0b1511b48db (patch) | |
| tree | 80ee1e07d11d81aaa0910642f9029ec5cbe0a57d /client/components/Folder/FileUploadButton.jsx | |
| parent | 1726a81b320e92ce412c0fa2b2b05f73798cc4ee (diff) | |
upload files
Diffstat (limited to 'client/components/Folder/FileUploadButton.jsx')
| -rw-r--r-- | client/components/Folder/FileUploadButton.jsx | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/client/components/Folder/FileUploadButton.jsx b/client/components/Folder/FileUploadButton.jsx new file mode 100644 index 0000000..8c7d170 --- /dev/null +++ b/client/components/Folder/FileUploadButton.jsx @@ -0,0 +1,44 @@ +import { h, Component } from 'preact' +import { Link } from 'react-router-dom' + +import Modal from '../Modal.jsx' + +import client from '../../client.js' + +import FileUploadButton from './FileUploadButton.jsx' + +export default class Folder extends Component { + constructor(props) { + super() + this.state = { + } + this.updateFiles = this.updateFiles.bind(this) + } + updateFiles(event){ + const name = event.target.name + const files = event.target.files + console.log(name, files) + + client.upload(this.props.folder.id, files).then( got_files => { + console.log(got_files) + this.props.addFiles(got_files) + }) + } + + render() { + console.log(this.props) + const files = (this.props.folder.files || []).map( (file, i) => { + return ( + <div key={i}> + {file.name} + </div> + ) + }) + return ( + <div class='fileUploadButton'> + <input type='file' multiple name='files' onChange={this.updateFiles} /> + <span>+ file</span> + </div> + ) + } +} |
