Download behavior is corrupting files
I have some download behaviors on a site which worked OK when I was using mySQL, but now that the site is running mySQLi it seems that the document encoding on Word, Excel files etc is becoming corrupted during the download process. The original files are fine and if I grab the uploaded files from the server, these are also fine. But when I use the download behavior to download the files, it will download OK but when I try to open it I either get an error message saying the file is corrupt and can't be opened, or it will attempt to open it but Word asks me to select the correct encoding and whatever type I choose, it won't open properly.
An example behavior would be:
<?php
WA_DFP_SetupDownloadStatusStruct("WA_DownloadResult1");
if(isset($_POST["download"]) || isset($_POST["download_x"])){
WA_DFP_DownloadFile("WA_DownloadResult1", "/downloads/", "".((isset($_POST["hiddenfield"]))?$_POST["hiddenfield"]:"") ."", "".((isset($_POST["hiddenname"]))?$_POST["hiddenname"]:"") ."", false, false, false, "", "", "", "");
}?>
<form method="post" action="" id="<?php echo $rsAppendicesIMPGI->getColumnVal("ID"); ?>" name="<?php echo $rsAppendicesIMPGI->getColumnVal("ID"); ?>">
<input name="hiddenfield" type="hidden" id="hiddenfield" value="<?php echo($rsAppendicesIMPGI->getColumnVal("Link")); ?>">
<input name="hiddenname" type="hidden" id="hiddenname" value="<?php echo($rsAppendicesIMPGI->getColumnVal("Title")); ?>">
<button type="submit" name="download" class="btn btn-primary"><i class="fal fa-download"></i></button>
</form>
I've attached an example of a downloaded file so that you can see what happens to it.