Thank you for your reply. The "correct" download from the admin panel is size 69120 bytes (size on disk 69632). The incorrect version is 69124 bytes (size on disk 69632). If I use FTP to download the file it is identical to the "correct" version in content and size.
I downloaded notepad++ and the incorrect version has two blank lines at the front. If I delete these in notepad++ and save back as a .doc file, it opens fine in word. If the code is identical then I can only assume that one or more of the variables in the code must be incorrect. Thank you for your help so far, I shall try and put some debug statmeents in the code to print out the variables.
The code is:
if($_GET["doc"])
{
$getdoc=mysql_query("select lname_auto,document_auto,doctype_auto from ".$this->prefix."candidate where id_auto='".$_GET["doc"]."' limit 1")
or die($this->lang["17"]." ".mysql_error()."\n");
$docarray=mysql_fetch_array($getdoc);
$grabext=explode('.',$docarray["document_auto"]);
header("Content-Type: ".$docarray["doctype_auto"]."");
header('Content-Disposition: attachment; filename="'.$docarray["lname_auto"].$_GET["doc"].'.'.$grabext["1"].'"');
$gethtml=file_get_contents($this->path2doc.$docarray["document_auto"]);
echo $gethtml;
}
From what you've said it looks like I should see what the variables used in the "header" statements are. Thank you