Create Zip file with content of current Directory with php – ZipCF

A few days ago I’ve shared a php script to unzip files. After that I received a few queries for a different script that will create zip files with content of current directory. And that’s why I am writing this article today.

Today, I’m going to share a php script that will create zip file using content of current directory. Its a very simple script and the workflow is simple as well!

Let’s know about how it works:

If you run the script it will find all the files, folders inside the folder (where you placed the script) and create a zip file inside this folder with all the files and folders.

With version 2.0, you can now select the files and folders you want to include in zip file. 

Here’s a video that explains features and way to use:

How to use ?

  • Simply click here to get the script
  • Upload zipCF.php on the directory which you want to make zip file
  • Open zipCF.php with your browser
  • Provide a Name for the zip file
  • Click on Create Zip file
  • It will create the zip file if everything is ok and provide a success message just below the submit button
  • If you see the success message, go to ftp client or browse direct url to zip file from your browser
  • Download the newly created zip file
  • Use it anyhow you need
  • Delete zipCF.php file from your server to avoid security issues

ZipCF - PHP based zip creation script - Create zip files even if you only have ftp login to server. | Product Hunt Embed

Questions/Comments ?

Please feel free to leave your comment using the comment box below.


Thanks to David Walsh for his very useful article which I’ve used to create this script.


38 Responses

  1. Woody says:

    Nice script! Thank you for sharing.

    Couple of questions please:

    1) Is there a way to set the directory wishing to ZIP? Lets say I have zipCF in one directory and wish to zip directory above (ie: ../).

    2) Is there a way to add directories to exclude from zip? I have a few directories that I wish to exclude (ie: data, temp)

    Thanks again for sharing.

    • Abdul Awal says:

      Hi Woody,
      Thanks for your comment.
      1. In current version of zipCF, There’s no option to select a directory. I’ll release an updated version soon & that version will have this option.

      2. No such option available with the script.

      Thanks again

    • zaid says:

      Hi when i open this file with browser it open like a html code?

      • Heyy Abdul!
        Same problem here. No idea, how to run that .php file on any browser (i copied it to a remote host directory via ftp). What requirements / dependencies it has in order to get to the login screen ..instead of displaying the folder structure and/or .php script? Thanks for any help man! Best wishes!

  2. payal says:

    Its Shows me below mention Error
    “503 Service Unavailable
    No server is available to handle this request. ”


  3. jess says:

    Hi, nice and useful script
    it doesn’t work here, I got this message:
    Warning: ZipArchive::close(): Read error: Is a directory in /htdocs/public/www/ on line 105
    Failed to create zip file, Please try again

    Any solution to this?

  4. jess says:

    Hi again,
    The mentioned error appears to be related to the php version, in v5.6 the script doesn’t works.
    But with v5.4.4 works fine!


  5. Anna Brown says:

    I uploaded the php file to the directory I wanted to zip but Im getting a 500 error. I can navigate to other files in that directory with my browser but not yours? Any idea?

  6. ts says:

    It doesn’t work here, I got this message:
    Warning: ZipArchive::close(): Read error: Is a directory in /home/td/ on line 105
    Failed to create zip file, Please try again

    Any solution to this?

  7. VF says:

    Great Work

  8. ryan says:

    Notice: Undefined offset: 1 in /var/www/fica/public_html/zipCF.php on line 120

  9. Waqas says:


    I am facing following error. Can you please guide me – how to resolve?

    ‘Failed to create zip file, Please try again ‘

    Thanks in advance.

  10. navas says:

    Great Work ,Thank you Abdul Awal

  11. 1stbootstrap says:

    Many Many thanks for great script.

  12. Nupur Ahuja says:

    Failed to create zip file

  13. mkelley says:

    Awesome script! Thanks for sharing! I also checked out the “unzip” script that you shared, love it! See here:

  14. Ritesh Kumar Sinha says:

    Hello , your script was very helpful . thank you ..

  15. torrey says:

    Looks nice except I get “Failed to create zip file, Please try again”
    so it doesnt seem to work
    have v 1.1
    any thoughts?

  16. mac says:

    It would be great, but it doesn’t add the empty folders to the zip file.

  17. aat says:

    Open zipCF.php with your browser , how to run it on the browser :-)…

  18. Chris says:

    good day,
    Please i tried using this script version 1.1 on my local environment Ampps and it seems not to be working, please help…

  19. david says:

    Awesome! I used in Chrome and I zipped more than 2Gb (15K files).
    Thank you for sharing!

  20. Guillaume says:


    In my use case, I’d only want to zip some of the files and directories stored in the main directory.
    Would you be willing to update your script to, say, read from a text file this list of files and directories?
    and zipCF-list.txt containing

    Or provide the same functionality any other practical way?

    Thank you.

  21. […] been a while since I started zipCF project in 2016. Many people used to visit the articles everyday which makes it obvious that the script became a little famous 😉 That’s […]

  22. Ankush Satija says:

    I am using your 2.0 script for download the zip but getting error failed to create zip can you please let me know what is issue over there.

    Can you please share me latest version script.

  23. Norbert says:

    Very useful thanks

Leave a Reply

Your email address will not be published. Required fields are marked *