Jump to content

Downloading pdf files


witt

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.
Link to comment
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.
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.