php - readfile function for PDF download issues -
i know question has been asked, solutions offered not working me. able download pdfs, adobe reader telling me it's either corrupt or decoded improperly. have alternative solution, or possible fix?
$path = "http://www.laerdalmail.com/discoversimulation/downloads/needs_assessment_form.pdf"; header('content-type: application/pdf'); header("content-transfer-encoding: binary"); header("content-disposition: attachment; filename=needs_assessment_form.pdf"); readfile($path); exit;
readfile should given filesystem path, not url. this:
$path = '/websitefolder/discoversimulation/downloads/needs_assessment_form.pdff'; // or $parh = 'c:\something\needs_assessment_form.pdff'; try adding in content length too:
header('content-transfer-encoding: binary'); header('content-length: ' . filesize($path));
Comments
Post a Comment