Perform the post request manually to be able to send the folder id with it

parent db0d5150
...@@ -20,14 +20,19 @@ ...@@ -20,14 +20,19 @@
:on-remove="handleRemove" :on-remove="handleRemove"
:on-success="handleSuccess" :on-success="handleSuccess"
:file-list="fileList" :file-list="fileList"
:headers="requestHeaders" :http-request="uploadFile"
style="display: inline-block; margin-right: 10px;"> style="display: inline-block; margin-right: 10px;">
<el-button size="small" type="primary" style="padding: 11px 9px;">Upload File</el-button> <el-button size="small" type="primary" style="padding: 11px 9px;">Upload File</el-button>
</el-upload> </el-upload>
</template> </template>
<script> <script>
import axios from 'axios'
export default { export default {
props: {
parentId: {type: Number}
},
data() { data() {
return { return {
fileList: [], fileList: [],
...@@ -49,6 +54,16 @@ ...@@ -49,6 +54,16 @@
this.$events.emit('fileWasUploaded', response); this.$events.emit('fileWasUploaded', response);
this.fileList = []; this.fileList = [];
}, },
uploadFile(event) {
let data = new FormData();
data.append('parent_id', this.parentId);
data.append('file', event.file);
axios.post(route('api.media.store'), data)
.then(response => {
this.fileList = [];
this.$events.emit('fileWasUploaded', response);
});
},
handleRemove() {}, handleRemove() {},
}, },
mounted() { mounted() {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment