dashboard.blade.php 2.62 KB
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
<link rel="stylesheet" href="{{ asset('AdminLTE/plugins/fontawesome-free/css/all.min.css') }}">
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<link rel="stylesheet" href="{{ asset('AdminLTE/plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css') }}">
<link rel="stylesheet" href="{{ asset('AdminLTE/plugins/icheck-bootstrap/icheck-bootstrap.min.css') }}">
<link rel="stylesheet" href="{{ asset('AdminLTE/dist/css/adminlte.min.css') }}">
<link rel="stylesheet" href="{{ asset('AdminLTE/plugins/summernote/summernote-bs4.min.css') }}">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-datetime-picker@2.5.11/jquery.datetimepicker.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.6.8/axios.min.js"></script>
        <script src="{{ asset("assets/js/vue.min.js") }}"></script> 
</head>
<body>
    <div class="wrapper">
    <div class="content-wrapper position-relative">
    <section class="contents">
        <div id="app" class="">
    <button class="btn btn-primary" @click="$refs.pdf.click()">
        <i class="fas fa-upload"></i> Upload PDF
    </button>

    <input
        type="file"
        ref="pdf"
        accept=".pdf"
        style="display:none"
        @change="upload_pdf"
    >
</div>
    </section>
</div>
</div>

<script type="text/javascript">
    var app = new Vue({
        el    : '#app',
        data:{
            ocr  : {!! json_encode($ocr) !!},
            ocr_window : null
        },
        mounted() {
            
        },
        methods:{
            upload_pdf(e){
                const file = e.target.files[0];
                if(!file) return;

                let formData = new FormData();
                formData.append('attached_file', file);

                axios.post("{{route('import_pdf')}}", formData, {
                    headers:{
                        'Content-Type':'multipart/form-data'
                    }
                }).then(res => {
                    this.ocr=res.data.ocr
                    if(res.data.status) alert('Upload thành công');
                    else alert('Upload false');
                }).finally(() => {
                    this.$refs.pdf.value = '';
                });
            }
        }
    })
</script>
</body>
</html>