Reputation: 107
Refer to Can an ASP.NET MVC controller return an Image? , the answer suggest to return image file from controller in C#.
My question is:
Can I do the same thing or similar in PHP? What I want is to hide PDF path from URL.
Thanks
Upvotes: 1
Views: 714
Reputation: 126
I think you are trying to hide the real local path of your pdf file using php. If this is the case, you can use something like this:
<?php
$localfilename = 'my_local_path/my_file.pdf';
header('Content-Type: application/pdf');
header("Content-Disposition: attachment; filename='download.pdf'");
readfile($localfilename);
?>
I hope this helps you. Greetings!
Upvotes: 4