emehrkay Posted May 16, 2006 Share Posted May 16, 2006 i have a misc class and i just added it as a method to that class[code]in my misc class public function exportFile($data, $filename){ header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=". $filename .""); header("Pragma: no-cache"); header("Expires: 0"); echo trim($data); }[/code]how i am callin it[code]LMS_Misc::exportFile("asdfasdF", "test.txt");[/code]my result is:" asdfasdF"**there is even a carriage return in therewhat am i doing wrong?thanksit looks like the .txt file starts of with a space then a return then two tabs Quote Link to comment https://forums.phpfreaks.com/topic/9805-im-getting-extra-whitespace-with-a-forced-file-download/ Share on other sites More sharing options...
ryanlwh Posted May 16, 2006 Share Posted May 16, 2006 maybe the octet-stream file-type tries to add some binary data before file content? Quote Link to comment https://forums.phpfreaks.com/topic/9805-im-getting-extra-whitespace-with-a-forced-file-download/#findComment-36363 Share on other sites More sharing options...
emehrkay Posted May 16, 2006 Author Share Posted May 16, 2006 i changed the filetype to csv and i get two little squares in front of the datait has somethign to do with the class that i am placing the method in. i put it in its own class and it is working fine. its time for me to go home so i will do some more testing tomorrow!!!! thanks Quote Link to comment https://forums.phpfreaks.com/topic/9805-im-getting-extra-whitespace-with-a-forced-file-download/#findComment-36370 Share on other sites More sharing options...
emehrkay Posted May 17, 2006 Author Share Posted May 17, 2006 acutally now that ived placed the function in its own class and file, i still get this error. its from me calling the class from a page that includes common.php (which sets the constant variables). i hae no idea what the problem is. any help Quote Link to comment https://forums.phpfreaks.com/topic/9805-im-getting-extra-whitespace-with-a-forced-file-download/#findComment-36683 Share on other sites More sharing options...
ryanlwh Posted May 17, 2006 Share Posted May 17, 2006 hmm.. try to move the pragma and expires header before content-type Quote Link to comment https://forums.phpfreaks.com/topic/9805-im-getting-extra-whitespace-with-a-forced-file-download/#findComment-36736 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.