[英]AWS PDF file show in bootstrep model in Laravel
我已經下載了aws url
https://xxx-xx-dev.s3.ap-south-1.amazonaws.com/std_check/6557122022151745398XtquBSY.pdf
當此 url 放入 ifrem 時,文件會自動下載,而不是引導模型中的視圖。 我的代碼在這里,
查看文件是
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);
}
}
});
}
控制器文件是
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);
}
那么,在 bootsrep 模型之后如何在 ajax succss 中讀取這個文件
readfile
函數將返回true
或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)});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.