
I updated answer of Morteza Ziaeemehr to a cleaner and better code, This will unzip a file provided within form into current directory using DIR. įont-family: 'Consolas', 'courier new', monospace I updated answer of to a cleaner and better code, This will unzip a file into current directory using _DIR_. extract it to the path we determined above $path = pathinfo(realpath($file), PATHINFO_DIRNAME) So, you could do: // assuming file.zip is in the same directory as the executing script.
Zip file extractor online free zip file#
ALWAYS SANITIZE USER INPUT.Īs per your comment, the best way to extract the zip file into the same directory in which it resides is to determine the hard path to the file and extract it specifically to that location. Use the $_GET superglobal instead.įinally, be very careful about accepting whatever input is passed to a script via a $_GET variable. $zip->extractTo('/myzips/extract_path/') Īlso, as others have commented, $HTTP_GET_VARS has been deprecated since version 4.1. There should be no need to use system calls for this. PHP has built-in extensions for dealing with compressed files.
Zip file extractor online free code#
On the other hand, the fact that this code could actually be published online somewhere as the correct way to unzip a file is a bit frightening.

I can only assume your code came from a tutorial somewhere online? In that case, good job trying to figure it out by yourself.
