52designs Posted August 14, 2008 Share Posted August 14, 2008 Hello I am making a website for a client and they are selling an eBook. On the page after they buy the eBook I want code so the user can not see the actual download link of the eBook. How can I accomplish this with php? I have the following code <?php $ebook = "http://www.52designs.net/something.pdf"; print "Click here to download eBook! <a href=\"".$ebook."\">Download</a>"; ?> But when I do this and go to the page it shows the actual book location. I do not want the link to show is there a way of doing this?\ Thanks Tim Hayes Link to comment https://forums.phpfreaks.com/topic/119737-solved-php-link-help/ Share on other sites More sharing options...
unkwntech Posted August 14, 2008 Share Posted August 14, 2008 There are 2 options 1 is to use javascript, the other is to make a PHP page that gets the file and outputs it directly, with the correct content type. The second option is better it will look somthing like this: <?php header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="filename.pdf"'); readfile('original.pdf'); ?> Link to comment https://forums.phpfreaks.com/topic/119737-solved-php-link-help/#findComment-616901 Share on other sites More sharing options...
52designs Posted August 14, 2008 Author Share Posted August 14, 2008 That might work but I want it to be where they can actually download the file. How can I do that? I want them to save it to their computer instead of opening it in the web browser. Or do you think it will be easier to just have it like that and just tell the user to save to their hard drive from there? Link to comment https://forums.phpfreaks.com/topic/119737-solved-php-link-help/#findComment-616916 Share on other sites More sharing options...
unkwntech Posted August 14, 2008 Share Posted August 14, 2008 That should cause a download if it does not then just link to that file, so they can click the link. Link to comment https://forums.phpfreaks.com/topic/119737-solved-php-link-help/#findComment-616917 Share on other sites More sharing options...
52designs Posted August 14, 2008 Author Share Posted August 14, 2008 Thanks for the help Link to comment https://forums.phpfreaks.com/topic/119737-solved-php-link-help/#findComment-616921 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.