Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: How to download zip with php without messy code


I want to download in my linux server.

And I got the Code from php offical web site. The url is

I have set content-Type: application/zip. But unlucky, when executing the download.php, I got Messy Code in firfox or chrome browser.

My linux charset and browser charset are both utf-8.

Here is my download.php code:

$file_name = "";
if (!file_exists ($file_name)){
echo "file is not exist";
header('Content-Description: File Transfer');
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename="'.basename($file_name).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file_name));

readfile ($file_name);

Compress code is:



$zip=new ZipArchive();
foreach($fileArr as $file)

However, I can download file with xftp from linux server, and decompressing successfully in my windows desktop.

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered

This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: How to download zip with php without messy code


Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription