Jump to content

Archived

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

witt

Downloading pdf files

Recommended Posts

I've tried several different methods an none have worked so far. Basically what I want is to a have a script named download.php that gets passed a file id via a link and then prompts the user with the option of saving the file. Retrieving the information for the file in question is not a problem, just the downloading part. Lets say that file name, file type (pdf in this case), file size and file location are already at your disposal, all that is needed is the code to prompt the user to dowload the file.

Share this post


Link to post
Share on other sites
[a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=95433\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=95433[/a] - you may find that useful

Share this post


Link to post
Share on other sites
[!--quoteo(post=387322:date=Jun 23 2006, 07:11 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 23 2006, 07:11 PM) [snapback]387322[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=95433\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=95433[/a] - you may find that useful
[/quote]

Unfortunately I don't. I get the same result as I've gotten with everything I've tried - the pdf gets corrupted and can't be opened.

Share this post


Link to post
Share on other sites
(1) May we see your code.

(2) What happens to the pdf file if you simply make a link to it?

ie
[code]
<A href="some.pdf">Click Me!<?a>
[/code]

Lite...

Share this post


Link to post
Share on other sites
Hmm, now I get this:

An appropriate representation of the requested resource /forums/index.php could not be found on this server.

when trying to reply.

Here is the code I had:

[code]header("Content-type: $file_type");
header("Content-Disposition: attachment; filename=$file_name");
echo $file;[/code]

This was used to display files retrieved from the database. The strange thing is that the above code stopped working 2 days ago and now all pdf files are corrupted. Anyways, I'd rather have the files downloaded from the server instead of the database.

...and this:


..and probably a about another 5 things. The pdf file always end up getting corrupted. I have no idea why the first code worked, and then suddenly stopped working today. It leads me to believe that some of the php settings were changed on the server, but I'm not sure.

If I simply link to the file I get prompted with the option to download and the file opens fine after it.

I tried a few other things, but for some reason I get an error why I try to post it in this message.

Share this post


Link to post
Share on other sites

×

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.