Jump to content

[SOLVED] PHP link help


52designs

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.