This is my file uploading function:
$file = $req->file('upload_file');
$name = $file->getClientOriginalName();
$fileName = time() . rand(1, 10000) . '_' . $name;
if($file) {
$storage = \Storage::disk('s3')->put($fileName, file_get_contents($file), 'public');
}
if ($storage) {
$savePdf = Pdf_exports::create(
[
'pdf_name' => $fileName,
]
);
}
I'm using jQuery DataTables to list the files. I'm creating the download links like so:
$('td:eq(6)', nRow).html('<div class="actionGrp"><a href="' + URL_general + '/dowlnoadPdf?id=' + aData.id + '" data-tooltip="tooltip" data-placement="top" title="Download"><span class="fa fa-download"></span></a></div>').addClass('txt-center');
How can I download the PDF directly when clicking the the download button?
Finally i got the Answer
return Storage::disk('s3')->download($pdf_name);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.