Jump to content


Photo

im getting extra whitespace with a forced file download


  • Please log in to reply
4 replies to this topic

#1 emehrkay

emehrkay
  • Staff Alumni
  • Advanced Member
  • 1,214 posts

Posted 16 May 2006 - 07:48 PM

i have a misc class and i just added it as a method to that class

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);
    }

how i am callin it

LMS_Misc::exportFile("asdfasdF", "test.txt");

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

#2 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 16 May 2006 - 07:56 PM

maybe the octet-stream file-type tries to add some binary data before file content?
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#3 emehrkay

emehrkay
  • Staff Alumni
  • Advanced Member
  • 1,214 posts

Posted 16 May 2006 - 08:18 PM

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

#4 emehrkay

emehrkay
  • Staff Alumni
  • Advanced Member
  • 1,214 posts

Posted 17 May 2006 - 06:18 PM

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

#5 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 17 May 2006 - 09:34 PM

hmm.. try to move the pragma and expires header before content-type
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users