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
Questions/Comments ?
Please feel free to leave your comment using the comment box below.
Credits
Thanks to David Walsh for his very useful article which I’ve used to create this script.
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.
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
Is it soon yet?
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!
Hi
Its Shows me below mention Error
“503 Service Unavailable
No server is available to handle this request. ”
Why…??
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/myweb.com/wp-content/uploads/2013/zipCF.php on line 105
Failed to create zip file, Please try again
Any solution to this?
Thanks!
Please check the latest version (1.1). It should work now.
Thank You
Where is the link to download this new version
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!
Thanks!
Hi Jess,
Thanks for pointing this. I’ll check it to understand what’s going wrong.
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?
It doesn’t work here, I got this message:
Warning: ZipArchive::close(): Read error: Is a directory in /home/td/.xxxxx.com/_backup/_oldrpclone/zipCF.php on line 105
Failed to create zip file, Please try again
Any solution to this?
To help you (and me !) , I have same problem, but it work with Folder with not a lot of files.
I’m looking for a solution.
Please check the latest version (1.1). It should work now.
Thank You
Great Work
Notice: Undefined offset: 1 in /var/www/fica/public_html/zipCF.php on line 120
Same error here 🙁
Hi,
I am facing following error. Can you please guide me – how to resolve?
‘Failed to create zip file, Please try again ‘
Thanks in advance.
Please check the latest version (1.1). It should work now.
Thank You
hello, looks like, you have permission issue of your directory, I had same issue, I made 777 , now its working.
Great Work ,Thank you Abdul Awal
Many Many thanks for great script.
Failed to create zip file
Please check the latest version (1.1) & let me know if its working.
Thank You
Awesome script! Thanks for sharing! I also checked out the “unzip” script that you shared, love it! See here: https://abdulawal.com/how-to-extract-zip-files-easily-on-web-server/
Hello , your script was very helpful . thank you ..
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?
It would be great, but it doesn’t add the empty folders to the zip file.
Open zipCF.php with your browser , how to run it on the browser :-)…
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…
Chris….
Awesome! I used in Chrome and I zipped more than 2Gb (15K files).
Thank you for sharing!
Hello,
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?
eg.:
/zipCF.php
/zipCF-list.txt
/included-dir/
/excluded-dir/
/included-file.php
/excluded-file.php
and zipCF-list.txt containing
included-dir
included-file.php
Or provide the same functionality any other practical way?
Thank you.
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.
Very useful thanks
Hi Abdul,
Great idea and Nice script!
Thank you for sharing your code, it solve an old problem.
When i set a password to my file it shows a blank page nothing else. otherwise it is running perfectly what should i do ?
After the address to the file you should type ‘?password=yourpassword’ . For example: https://mywebsite.com/wp-content/plugins/ZipCF.php?password=123456
I couldn’t back up my website because I ran out of space on my server which is misconfigured by me. Probably you know the answer, dev/sda1 was seems full and i still couldn’t figure it out what the hell am i suppossed to do. That’s why Duplicator and alternatives getting stuck at the limits. Fortunately, thanks to your script, I was able to back up my entire site and download it to my computer in 10 minutes. I am still newbie this managing a VPS thing and want to thank you for your great solution. Have a nice day and keep up the good work. Best wishes from Turkey.
It works like a charm. It saved my life (or at least my work) many times. Thank you very muchas gracias!
Thank You Abdul, it works fine for me. Robert
You must be really crazy creating that script for free. On the other hand, it is not always about money but it feels much better when helping others. So, congrats, you are a great person firstly and a brilliant developer secondly. Thank you for sharing this great script.
Thanks for sharing this solution and script. 🙂