Jump to content


Photo

Downloading pdf files


  • Please log in to reply
5 replies to this topic

#1 witt

witt
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 23 June 2006 - 11:16 PM

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.

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 24 June 2006 - 12:11 AM

[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
Legend has it that reading the manual never killed anyone.
My site

#3 witt

witt
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 24 June 2006 - 01:41 AM

[!--quoteo(post=387322:date=Jun 23 2006, 07:11 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 23 2006, 07:11 PM) View Post[/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.

#4 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 24 June 2006 - 01:48 AM

(1) May we see your code.

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

ie
<A href="some.pdf">Click Me!<?a>

Lite...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#5 witt

witt
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 24 June 2006 - 02:03 AM

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:

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

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.

#6 witt

witt
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 24 June 2006 - 02:49 PM

Any ideas?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users