Add MediaUpload component.

This commit is contained in:
Roger Braun 2016-11-06 19:28:37 +01:00
parent dcb7fd1440
commit a73916dd7f
2 changed files with 39 additions and 0 deletions

View file

@ -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

View file

@ -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>