Add MediaUpload component.
This commit is contained in:
parent
dcb7fd1440
commit
a73916dd7f
|
@ -0,0 +1,22 @@
|
|||
/* eslint-env browser */
|
||||
import statusPosterService from '../../services/status_poster/status_poster.service.js'
|
||||
|
||||
const mediaUpload = {
|
||||
mounted () {
|
||||
const store = this.$store
|
||||
const input = this.$el.querySelector('input')
|
||||
const self = this
|
||||
|
||||
input.addEventListener('change', ({target}) => {
|
||||
const file = target.files[0];
|
||||
const formData = new FormData();
|
||||
formData.append('media', file);
|
||||
statusPosterService.uploadMedia({ store, formData })
|
||||
.then((fileData) => {
|
||||
self.$emit('uploaded', fileData)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default mediaUpload
|
|
@ -0,0 +1,17 @@
|
|||
<template>
|
||||
<div class="media-upload">
|
||||
<label class="btn btn-default">
|
||||
<i class="fa icon-upload"></i>
|
||||
<input type=file style="position: fixed; top: -100em"></input>
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script src="./media_upload.js" ></script>
|
||||
|
||||
<style>
|
||||
.media-upload {
|
||||
font-size: 26px;
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue