How to unzip a file on a remote server
Moderator: General Moderators
How to unzip a file on a remote server
I need to be able to call upon a remote .zip file located at an http:// address, unzip it, and store the contents in a directory in my server. How can this be done using PHP?
Re: How to unzip a file on a remote server
The easiest way would be to shell (ha) out the work to the system. Meaning, let PHP do the bare minimum necessary.
On Unix-based systems,
On Unix-based systems,
Code: Select all
// download
exec("wget http://www.example.com/path/to/file.zip -O file.zip"); // save as "file.zip"
// unzip
exec("unzip file.zip"); // extract to the same directory
exec("unzip file.zip -d file/"); // extract to ./file/Re: How to unzip a file on a remote server
1) download a file using any method possible
2) use PHP Zip extension if possible or download any Zip class from the internet to unpack it
2) use PHP Zip extension if possible or download any Zip class from the internet to unpack it
Re: How to unzip a file on a remote server
I think I know how to unzip a local file, but the problem is making the file local. How can I use PHP to retrieve an external file and place it in a directory on my server?