Re: New Line Character while downloading a file!
| From: | Divick Kishore | Date: | Fri, 24 Sep 2004 11:32:40 +0000 |
| Subject: | Re: New Line Character while downloading a file! | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-197769@lists.php.net to get a copy of this message | ||
Thanks for pointing that out. But still it doesn't solve my problem.
Thanks for a prompt response.
"Marek Kilimajer" <lists@kilimajer.net> wrote in message
news:4153FEF0.30703@kilimajer.net...
> Divick Kishore wrote:
> > Hi,
> > I am a newbie to php so pls be gentle.
> >
> > I am having problems while downloading a file via this script. I am
sending
> > the following headers and then a call to readfile function in the
swcript.
> > This leads to opening of a download popup but the file name being shown
is
> > the name of the script file rather than of the file which I am forcing
the
> > user to download. Another problem is that when the file is downloaded a
new
> > line character is added to the top of it unncessarily due to which it
can't
> > be opened with any image viewer.
> > Once I reomove that newline character, it works fine.
> >
> >
> > Script.php
> >
> > //some validations go here.
> >
> > $relative_file =
> >
> > "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).
> > "/../Dir/".$fileName;
>
> Why are you reading the file through http when it's on the same server?
Try
>
> $relative_file = "../Dir/".$fileName;
>
>
> > header('Content-type: image/jpeg');
> > header('Content-Disposition: attachment; filename=' . $relative_file);
>
> $relative_file contains "http:// ..... and so on".
> You should use
$fileName
>
> > @readfile($relative_file);
> >
> > Thanks in Advance,
> > Kishore Divick.
> >