HELP! Force download code is not working

Hi!

I am trying download the zip file using the below code: The problem is, In IE, it's not allowing me to download the file. It works fine in Firefox.

header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"somename.zip\"");                  

FYI,

1. The file type/content-type in the IE download window is blank.
2. I tried using application/zip, application/x-zip and it didn't work.
3. I am creating the zip file using exec() command in my code.
4. In firefox the filetype comes as WINRAR ZIP ARCHIVE.

Please help me in resolving this.

Thanks in advance,
S:

LVL 5
prsupriyaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

geir_andersenSystems engineerCommented:
I just answered another question with this code..
This is the code I use to download files:
<?php
$thefile = "test.zip";
header("Content-type: application/octet-stream");
header("location: {$thefile}");
?>

It'll bring up the download dialogue.
(Tested in IE and FireFox)

-Geir

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nicholassolutionsCommented:
I trust Geir's code will work fine. Yours is OK too, I think, but it looks like you just forgot to actually output the file:

header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"somename.zip\"");    
         
readfile('path/to/somename.zip');             //this is the line you need to add, to read out the zip you created.

Hope that helps,
Matt
prsupriyaAuthor Commented:
Hi! geir_andersen, the solution you gave worked great...thanks!

nicholassolutions, readfile() was already there in my code. thanks!
geir_andersenSystems engineerCommented:
no problem, great it worked out for you.
Thanks for the points.

-Geir
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.