Bhagyashree_ABZWebdev Posted July 4, 2019 Share Posted July 4, 2019 Hello, I am creating zip file of multiple files using PHP and downloading it. Problem is that: zip file is getting extracted by only WinRAR, its not getti ng extracted by default windows extracter or other software. Here is code which I have written - $file_folder = 'referral-resume/'; if(extension_loaded('zip')) { if(isset($_POST['files']) and count($_POST['files']) > 0) { $zip = new ZipArchive(); $zip_name = "referralresumes".time().".zip"; if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE) { $error .= "* Sorry ZIP creation failed at this time"; } foreach($_POST['files'] as $file){ $zip->addFromString(basename($file_folder.$file), file_get_contents($file_folder.$file)); } $zip->close(); if(file_exists($zip_name)){ header('Content-type: application/zip'); header('Content-Disposition: attachment; filename="'.$zip_name.'"'); readfile($zip_name); unlink($zip_name); } } else{ $error .= "* Please select file to zip "; } } else{ $error .= "* You dont have ZIP extension"; } Quote Link to comment Share on other sites More sharing options...
requinix Posted July 4, 2019 Share Posted July 4, 2019 If you want Windows to use the built-in ZIP handler then you need to tell Windows to use the built-in ZIP handler. PHP has nothing to do with it. Quote Link to comment Share on other sites More sharing options...
Bhagyashree_ABZWebdev Posted July 4, 2019 Author Share Posted July 4, 2019 (edited) Thank you for reply..but my problem is that when I Use any other software or windows extractor to extract that file..its giving error as file invalid...but same file getting extracted with winrar..thats the main issue Edited July 4, 2019 by Bhagyashree_ABZWebdev Quote Link to comment Share on other sites More sharing options...
requinix Posted July 4, 2019 Share Posted July 4, 2019 Ohh, okay, that's what you meant. Can you upload a sample of what it produces? Quote Link to comment Share on other sites More sharing options...
Bhagyashree_ABZWebdev Posted July 4, 2019 Author Share Posted July 4, 2019 Its just saying file is invalid... Quote Link to comment Share on other sites More sharing options...
Bhagyashree_ABZWebdev Posted July 4, 2019 Author Share Posted July 4, 2019 Issue resolved.thanx Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 4, 2019 Share Posted July 4, 2019 Care to share? I mean - you posted a problem and then suddenly you solved it! Well - what did you do? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.