<script setup>
import Api from "../../api/index.js";

const emits = defineEmits(['success']);

const upload = (e) => {
    const file = e.target.files[0];
    Api.system.uploadFile2(file).then(({data}) => {
        emits('success', data);
    });
}

const createInput = () => {
    const input = document.createElement('input');
    input.type = 'file';
    input.onchange = upload;
    input.style.display = 'none';
    document.body.append(input);
    input.click();
}
</script>

<template>
    <div @click="createInput">
        <slot></slot>
    </div>
</template>

<style scoped lang="scss">

</style>
