I have a lightbox with a form, when the user sends the form a download should start, this is the code I use:
function start_download( $path, $item ) {
$file = $path.$item;
header("Content-type:application/pdf");
header('"Content-Disposition:attachment;filename="'.$file.'"');
}
Unless the fact that is a function is a problem, I think it should work right? well it doesn’t. No error whatsoever.
Looking at Chrome’s developer tools I can see that the headers are actually set application/pdf.
Oh, also, when I add readfile($file) it seems to read the file but it returns a strange string (numbers and weird symbols).
I searched over this site but nothing seems to work. I really don’t know what else can I do. Ideas?
BTW if I “echo” the $file it shows the url correctly, I don’t think that is the problem.
Try the following: