Connecting Tech Pros Worldwide Help | Site Map

how to write php function to download file

Familiar Sight
 
Join Date: Nov 2007
Posts: 235
#1: Mar 14 '08
Hi

I want to give user a facility to download content so how can I do it using php
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#2: Mar 14 '08

re: how to write php function to download file


Quote:

Originally Posted by mukeshrasm

Hi

I want to give user a facility to download content so how can I do it using php

here
Scroll down to the part about content disposition.
Familiar Sight
 
Join Date: Nov 2007
Posts: 235
#3: Mar 17 '08

re: how to write php function to download file


Quote:

Originally Posted by markusn00b

here
Scroll down to the part about content disposition.

I tried this code
Expand|Select|Wrap|Line Numbers
  1. header('Content-type: application/pdf');
  2.  
  3. // It will be called downloaded.pdf
  4. header('Content-Disposition: attachment; filename="book.pdf"');
  5.  
  6. // The PDF source is in original.pdf
  7. readfile('book.pdf');
  8.  
but in the browser it shows only some garbage values.
harshmaul's Avatar
Expert
 
Join Date: Jul 2007
Posts: 483
#4: Mar 17 '08

re: how to write php function to download file


the browser probably hasn't got a plug in for pdf files
Familiar Sight
 
Join Date: Nov 2007
Posts: 235
#5: Mar 18 '08

re: how to write php function to download file


Quote:

Originally Posted by harshmaul

the browser probably hasn't got a plug in for pdf files

which kind of plugin browser requires and will the same doce work for text or doc file.
harshmaul's Avatar
Expert
 
Join Date: Jul 2007
Posts: 483
#6: Mar 19 '08

re: how to write php function to download file


which browser are you using?

downloads available at
http://www.adobe.com/downloads/
Reply