You are here: Re: Looking for a script to download pdf file from server « PHP Programming Language « IT news, forums, messages
Re: Looking for a script to download pdf file from server

Posted by Rik on 12/18/97 11:48

Dynamo wrote:
> Many thanks but somehow I dont think that snippet of code on its own
> will do what I want. I was looking for the complete code. I have
> tried the following but it failed miserably. What am I doing wrong?
>
> <?php
> $dir_name = "/books/";
> $file = "downloadtest.pdf";
>
> $content = file_get_contents($dir_name . $file);
>
> header('Content-Type: pdf');
> header('Content-Length: ' . filesize($dir_name . $file));
> header('Content-Disposition: 'attachment');
> echo $content;


1. Turn on error reporting, if this is you script, it will tell you some
interesting things.
2. Is /books/ in your root? If not, you can't refer to it like this. Does
content indeed hold the file, or just 'false"?

Also:
it's header('Content-type: application/pdf');


The exact syntax is in the php-manual as an example for header...
http://nl3.php.net/en/header

header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="name_give_to_user.pdf"');
readfile('/path/to/original.pdf');

Grtz,
--
Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация