You should check very carefully strings
in header() calls (a very common mistake) :
for instance I'm quite sure there's a
space after"Content-disposition:attachment"
should be "Content-disposition: attachment"
there\'s also a space after the ';' (before
"filename=")
and last : you're using two differents
variables for the file name :
in the fopen() you're using "$filename"
and in the header() calls you're using
"$thisfile"