Skip to content
Advertisement

Show PDF without path in URL

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

Advertisement

Answer

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!

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement