[PHP] get zip file when visiting browser

With Apache + PHP
This code allows us to download a file zip from browser:


<?php

    $your_zip_file = "/path/to/your_zip_file.zip";

    $file_name = basename($yourfile);

    header("Content-Type: application/zip");
    header("Content-Disposition: attachment; filename=$file_name");
    header("Content-Length: " . filesize($your_zip_file ));

    readfile($your_zip_file );
    exit;

?> 
Advertisements

4 comments on “[PHP] get zip file when visiting browser

  1. Magnificent website. Lots of useful info here. I’m sending it to several pals ans additionally sharing in delicious. And certainly, thanks for your sweat!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s