On my site based on CodeIgniter (member management system), it is possible to create files with direct debit. They are downloaded by setting the headers as described here: http://www.richnetapps.com/the-right-way-to-handle-file-downloads-in-php/ . However, for some reason, an empty string is always output before my own output. I tried replacing all the lines of the newline in the line that I was returning, without success. The output is an XML file, and my bank does not accept the file as valid XML because of this empty string.
I have already found posts that say that this is most likely due to the closure of PHP tags in the files before the current file. This may be the reason, but several third-party libraries are loading, and manually deleting all closing PHP tags in each file is canceled if you still want to keep the ability to update your libraries. Smarty seems to love these closing tags.
Direct access to the file itself is also not an option, because CodeIgniter does not allow this by default, and because this method poses a rather serious security problem (public files with bank account data are big no-no),
Therefore, I come to you: do you know another possible solution to this problem?
Edit: This is the code used to download.
function incasso_archive($creditor, $date, $time, $extension) { $date = str_replace("_", "-", $date); $fn = $this->incasso->incasso_file($creditor, $date, $time, $extension); $contents = file_get_contents($fn); $name = "Incasso $date.$extension"; header('Content-Type: application/octet-stream'); header('Content-Transfer-Encoding: Binary'); header('Content-disposition: attachment; filename="'.$name.'"'); echo $contents; }
source share