I'm trying to add code to let the visitor download a ZIP file, then show some HTML follow-up. Here's what I'm trying:
Code: Select all
<?php
...
header( "Content-type: application/x-zip-compressed" );
header( "Content-Disposition: attachment; filename='example.zip'" );
readfile( "source.zip" );
?>
<html>
...
</html>Instead of downloading the ZIP, it displays the contents in raw text form. This happens whether or not I include Content-length. The only difference then is whether it shows the follow-up HTML.
I've tried other MIME types, too, including
applicaton/zip
multipart/zip
application/octet-stream
All give the same result. I've even tried excluding the Content-type header altogether to see if PHP could figure it out.
Is there maybe a server setting that I'm not aware of? My gut tells me it has to do with either the MIME type or readfile. If so, what's the alternative?
This is a hosted account, so I don't have root access. Also, it's PHP4.
(Just refreshed and still not working. Maybe after I hit submit...)