So what's the value of '$filename' and why is it quoted? That will literally try to save the file to a file called $filename (not the value of the $filename variable, but actually called $filename) on your server.
Save to 'php://output' if you want to send the file to the browser
Save to 'php://output' if you want to send the file to the browser