|
Posted by Jean-Baptiste Nizet on 10/19/07 11:42
On 19 oct, 13:07, "salonowiec" <debrza_removet...@poczta.onet.pl>
wrote:
> My very basic code is:
> <?php
> $fname='alpha.ext';
> readfile($fname);
> ?>
> Only when ext is txt I'm getting a reasonable content, otherwise there's a
> lot of bush. What function should I use to open doc, xls, pdf, gif?...
> Can you help to a supernewbie???
If what you want to do is sending a gif, jpeg, pdf file or whatever
file to the browser and the browser displays it as it would if you had
clicked on a direct link to the file, then you must send the mime type
of the file in the HTTP response:
header("Content-Type: image/gif");
for a gif file, for example.
With direct links, the web server does it automatically, but if you
want to do it in PHP, you have to do it yourself. Read the user
comments on http://www.php.net/readfile to see some examples.
JB.
Navigation:
[Reply to this message]
|