I have a system for downloading PDF files, what is happening and what I try to download, and it simply does not download. I have seen in the chromo inspector and no error.
Controller
class DownloadController extends Controller{
public function getDownload (){
$filename = 'certificacoes/teste.pdf';
$path = storage_path($filename);
return Response::make(file_get_contents($path), 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="'.$filename.'"'
]);
}
}
Jquery
$(function(){
$("body").on('click', '#download_link', function(e) {
e.preventDefault();
var creditos = {{$creditos}}
if(creditos == 0){
sweetAlert("Erro...", 'Não tem créditos disponiveis. Efectue upload de uma certificação', "error");
}else{
$.ajax({
type: 'POST',
url: '/download',
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
//data: formData
}).done(function(response) {
}).fail(function(data) {
sweetAlert("Erro...", 'Ocorreu um erro ao efectuar o download. Por favor tente novamente!', "error");
});
}
});
});