我已经下载了 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 中读取此文件
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
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)}); }