Jump to content

zipping folder


abdelelbouhy

Recommended Posts

hi guys i'm having a problem zipping files to folder what is happing the script zip the folder and add some files to that folder then it download the folder but when i unzip the folder i find empty files with 0 KB but when i download via FTP( the unzipped files) contain content any idea the code is like that $zip = new ZipArchive; generate the filegenerateAmazonSkuCSV($arra_sku_uk,$csvsavefilepath,'cb_uk');$csvdowloadfilepath = 'files/csv/amazoninventorysku/';$file_type = 'application/csv';$file_name = "cb_uk_amazon_stock.csv";$file = DIR_FS_ADMIN.$csvdowloadfilepath . $file_name;if ($zip->open(DIR_FS_ADMIN.$csvdowloadfilepath .'changingbag_skus.zip', ZIPARCHIVE::CREATE) != TRUE) {die ("Could not open archive");}$zip->addFile($csvsavefilepath,$file_name);$zip->addFile($csvsavefilepath,$another_file);$zip->close();then download the file $file_found = downloadAmazonSkuFile( $file, $file_name, $file_type ); the function for downloadfunction downloadAmazonSkuFile( $file, $file_name, $file_type ){ if( ! is_file( $file ) ){return false; } $filesize = filesize( $file ); header('Content-Description: File Transfer');header('Content-Type: application/octet-stream');header('Content-Disposition: attachment; filename='.basename($file));header('Content-Transfer-Encoding: binary');header('Expires: 0');header('Cache-Control: must-revalidate, post-check=0, pre-check=0');header('Pragma: public');header('Content-Length: ' . filesize($file));ob_clean();flush();readfile($file); return true; }#func many thanks

Link to comment
Share on other sites

If that variable contains a folder then that is the problem, you're telling it to zip a folder which has no data, which is why the filesize is 0. The first parameter to addFile is the full filename you want to add, check the documentation for that method for more information about how it works.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...