Jump to content

im getting extra whitespace with a forced file download


emehrkay

Recommended Posts

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 there

what am i doing wrong?
thanks

it looks like the .txt file starts of with a space then a return then two tabs
i changed the filetype to csv and i get two little squares in front of the data


it 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
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.