Click here to Skip to main content
15,904,155 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I'm creating zip files to update through recovery of custom roms.

My web app creates a zip, if I use it (copying from www/webapp to phone) it's all ok. But when I download it through browser, that I do using: ($zipfile is "something.zip")

MIDL
// Send file headers
    header("Content-type: application/zip");
    header("Content-Disposition: attachment;filename=$zipfile");
    readfile($zipfile);


I can see and open it in my PC (it looks perfectly ok) but in my phone I get "can't open something.zip - (bad).

I already tried a lot of combinations of headers parameteres but no sucess. The file is also a couple KB larger than the original one (the one it works, at webapp directory) - i dont know if it's suppose, but it's something different.

Can you help me please?
Posted
Updated 9-Apr-11 17:17pm
v2

1 solution

That would be the solution

C#
if (file_exists($zipfile)) {
        header('Content-Description: File Transfer');
        header('Content-Type: application/zip');
        header('Content-Disposition: attachment; filename='.basename($zipfile));
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
        header('Content-Length: ' . filesize($zipfile));
        ob_clean();
        flush();
        readfile($zipfile);
        exit;
    }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900