Unfortunately, I can't post a url to the page I'm working on. It contains customers information..etc etc.
I'm using the USPS Web Tools API to generate shipping labels from the information provided from our database. When I create a label, I decode it, and dump it into a file with fopen,fwrite,fclose.
The file works, I can browse to it and open it to see the label. When the file is saved, I want it to be pushed to the header and force a download. Basically, so we can just open it print, and slap it on the box.
I am using the following code:
Instead of file download box, I get a huge gray box that says: "The page at ... says:", and it basically dumps the file there.
if( !file_exists($file) ) die("File not found");
// Force the download
header("Content-Disposition: attachment; filename=\"" . basename($file) . "\"");
header("Content-Length: " . filesize($file));
I've tried google, and tried most of the scritps I've found, and they all do the same thing. Perhaps this is browser related? I'm using Firefox 3.5.2.