Re: Filename problem with file downloading
| From: | Alex Shi | Date: | Mon, 26 May 2003 02:09:17 +0000 |
| Subject: | Re: Filename problem with file downloading | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-148947@lists.php.net to get a copy of this message | ||
Here is the code:
<?
// .....
$wll_count = 64;
$wll_seqn = 9;
$wll_name = 'TheName.'.$wll_count.'.'.str_pad ($wlseqn, 2, '0',
STR_PAD_LEFT);
$mime_type = 'text/x-txt';
header ('Content-Type: ' . $mime_type);
if ($HTTP_USER_AGENT == 'IE') {
header ('Content-Disposition: inline; filename=' . $wll_name);
header ('Expires: 0');
header ('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header ('Pragma: public');
} else {
header ('Content-Disposition: attachment; filename=' . $wll_name);
header ('Expires: 0');
header ('Pragma: no-cache');
}
print $wll_buffer;
// .....
?>
It's strange that if remove the middle part or the end part of the file
name,
say, "TheName.64" or "TheName.09", there will be no "[1]" added.
thanks!
Alex Shi
"Justin French" <justin@indent.com.au>
:BAF7A306.27C20%justin@indent.com.au...
> You'd have to show us the code which establishes the value of $filename,
> rather than the header() code.
>
> Justin
>
>
> on 26/05/03 10:24 AM, Alex Shi (chpshi@eol.ca) wrote:
>
> > Hello,
> >
> > Several days ago I posted question asking about how to handle file
> > downloading file in php. Thanks for those who answered me with their
> > help I learned a lot about it. But still I have problem with filename.
The
> > file downloading code is like following:
> >
> > <?php
> >
> > // ......
> > header ("Content-type: application/octet-stream");
> > header ("Content-Disposition: attachment; filename=" . $filename);
> > header ("Pragma: no-cache");
> >
> > readfile ($filename);
> >
> > // .....
> > ?>
> >
> > Everything is ok except the $filename. I want the name to be created
> > in this format: FileName.[record#].[seqence#]. Say, FileName.64.023.
> >
> > The problem is, no matter how I create the value for $filename, the
> > filename generated at the local end on downloading will always like
> > this: FileName[1].64.023. The "[1]" is automatically added and I don't
> > understand why it was added there.
> >
> > Maybe this is not a php problem but I have no clue where can find the
> > answer and solution to fix it. This looks a tiny issue but a big
headaque
> > to me. Please give me a hand if any one out there happen to know this.
> > Many thanks in advance!
> >
> > Alex Shi
> >
> >
> >
> >
>