abdelelbouhy Posted February 21, 2013 Share Posted February 21, 2013 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 More sharing options...
justsomeguy Posted February 21, 2013 Share Posted February 21, 2013 Does $csvsavefilepath contain the full filename to add to the archive? Link to comment Share on other sites More sharing options...
abdelelbouhy Posted February 21, 2013 Author Share Posted February 21, 2013 the full path is like that ADMIN . 'files/csv/amazoninventorysku/ the folder got created and zipped and the files is added to it but it's empty Link to comment Share on other sites More sharing options...
justsomeguy Posted February 21, 2013 Share Posted February 21, 2013 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 More sharing options...
abdelelbouhy Posted February 21, 2013 Author Share Posted February 21, 2013 many thanks is there is anyway in php let me download more than a file in one http request the problem is after i create the five files i need to download them all together that why i'm trying to zip them Link to comment Share on other sites More sharing options...
justsomeguy Posted February 21, 2013 Share Posted February 21, 2013 Yeah, zip is the way to do that, you can't send more than one file at once. We do the same thing here, just zip them. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now