Jump to content

Archived

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

emehrkay

im getting extra whitespace with a forced file download

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

Share this post


Link to post
Share on other sites
maybe the octet-stream file-type tries to add some binary data before file content?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
hmm.. try to move the pragma and expires header before content-type

Share this post


Link to post
Share on other sites

×

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.