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粉3149159222024-04-05 10:12:12
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)}); }