i want to be able to click on a link and it downloads a file from laravel public folder, please i need to see the routes and controller to i need to write to achieve this.
could do achieve this via php only:
if (isset($_GET["download"])){
$search = $_GET["download"];
$dir = $clipDir->clip_path1($search);
$Base = basename($dir);
if (file_exists($dir)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$Base);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($dir));
ob_clean();
flush();
readfile($dir);
exit;
} else {
echo 'File Dont Exit <br />'. print_r($dir);
return false;
}
file are stored in laravels public folder
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire