I am getting the response by Third party API call. They providing me a file_url in response. If I hitting the file_url in browser URL got the zip file on local machine.
stdClass Object
(
[start_date] => 2018-06-01 08:00:00
[report_date] => 2018-07-02
[account_name] => Maneesh
[show_headers] => 1
[file_url] => https:examplefilename
[date_range] => 06/01/2018 - 07/03/2018
)
How can I download the zip file on public/phoneList folder on server and unzipped the file?
$fileUrl = $rvmDetails->file_url;
$zip = realpath('/phoneList/').'zipped.zip';
file_put_contents($zip, file_get_contents($fileUrl));
$zip = new \ZipArchive();
$res = $zip->open('zipped.zip');
if ($res === TRUE) {
$zip->extractTo('/phoneList/'); // phoneList is folder
$zip->close();
} else {
echo "Error opening the file $fileUrl";
}
The above code works. but getting issue while unzipp the folder.
ZipArchive::extractTo(): Permission denied