Display AWS PDF files in Bootstrap mode in Laravel
P粉418351692
P粉418351692 2024-04-04 22:16:18
0
1
1436

I have downloaded the aws url, for example

https://xxx-xx-dev.s3.ap-south-1.amazonaws.com/std_check/6557122022151745398XtquBSY.pdf

When this url is put into an ifrem, the file will be downloaded automatically instead of bootstrapping the view in the model. My code is here,

View file is

function PDFOPEN(path) {
    $.ajax({
        type: 'post',
        url: '{{ route('background.pdf.show') }}',
        data: {
            "_token": "{{ csrf_token() }}",
            'path':path
        },
        success: function(data) {
            if (data.status == true) {
            
            } else {
                toastr.error(data.message);
            }
           
        }
    });
}

The controller file is

public function BackgroundVerifyShow(Request $request)
    {
        $file = \Storage::disk('s3')->url($request->path);
        header('Content-Type: application/pdf');
        header(sprintf("Content-disposition: inline;filename=%s", basename($file)));
        @readfile($file);
    }

So, how to read this file in ajax succss after bootsrep model

P粉418351692
P粉418351692

reply all(1)
P粉314915922

The

readfile function will return true or false.

public function BackgroundVerifyShow(Request $request)
    {
        $file = \Storage::disk('s3')->url($request->path);

        header('Content-Type: application/pdf');
        header(sprintf("Content-disposition: inline;filename=%s", basename($file)));
        header("Content-Type: " . $asset->mime);

        echo json_encode({status => readfile($file)});
    }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!