I have solve the previous problem and now it create a zip file and add all the files from a specific folder, but the zip file is not where I want it to be, the zip file is just in the public folder, how do I make it so that the zip file is created and in the company folder?
$companyLogoURL = '';
if ($companyLogo) {
//create folder if not exist
$destinationPath = 'uploads/company/';
if (! file_exists($destinationPath)) {
mkdir($destinationPath, 0777, true);
}
$imageExt = $companyLogo->getClientOriginalExtension();
$imageName = time().$customer_id.'.'.$imageExt;
$imageFormats = ['jpg', 'png', 'gif', 'bmp', 'jpeg', 'PNG', 'JPG', 'JPEG', 'GIF', 'BMP','svg'];
//check video validation
$getFileSize = $companyLogo->getSize();
if ($getFileSize <= $this::FILE_SIZE_THREE_MB) {
if (in_array($imageExt, $imageFormats)) {
$companyLogo->move($destinationPath, $imageName);
$companyLogoURL = $imageName;
$zip = new ZipArchive();
$zip_name = $imageName.".zip";
if($zip->open(public_path($zip_name), ZIPARCHIVE::CREATE)===TRUE){
$files = File::files(public_path('uploads/company'));
foreach($files as $key => $value){
$samefileNameinZip = basename($value);
$zip->addFile($value, $samefileNameinZip);
}
$zip->close();
}
}
Please let me know if you have any advice or anything I did wrong that you notice.
Thank you, much appreciated.