RE: [PHP-DB] help with file downloads from MySQL
| From: | Mickey Martin | Date: | Fri, 24 Mar 2006 20:53:17 +0000 |
| Subject: | RE: [PHP-DB] help with file downloads from MySQL | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-41605@lists.php.net to get a copy of this message | ||
I guessed that 0a is the code for a new line, but cannot find where it is in
my code. This is the entire code that I'm using for the download:
<?php
if ($id_files) {
mysql_select_db($database_ctnwww, $ctnwww);
$query_Attachment = sprintf("SELECT bin_data, filetype, filename, filesize
FROM IssueAttach WHERE id_files=%s", $_GET['id_files']);
$Attachment = mysql_query($query_Attachment, $ctnwww) or die(mysql_error());
$row_Attachment = mysql_fetch_array($Attachment);
$data = $row_Attachment['bin_data'];
$name = $row_Attachment['filename'];
$size = $row_Attachment['filesize'];
$type = $row_Attachment['filetype'];
header("Content-type: $type");
header("Content-length: $size");
header("Content-Disposition: attachment; filename=\"$name\"");
header("Content-Description: PHP Generated Data");
echo $data;
}
?>
I have also tried putting a string in front of the file on the echo line:
echo "TEST TEXT", $data;
When the file is saved, it begins with 0a followed by TEST TEXT and then the
start of the file without another instance of 0a.
Mickey
-----Original Message-----
From: Oskar [mailto:oki2003@volny.cz]
Sent: Friday, March 24, 2006 1:59 AM
To: Mickey Martin; PHP db
Subject: Re: [PHP-DB] help with file downloads from MySQL
Mickey Martin wrote:
> From what I can tell, the 0a is not in the file, but is being inserted
>either with the echo or by the browser when it receives the file. Does
>anyone know if a proxy server would cause this? There shouldn't be one
>involved, but I am going to contact my IT department to find out how it
>is configured today.
>
>Thanks,
>Mickey
>
>
>
>
>
0a is new line character code. Check your script you must be somewhere
displaying it.