|
![Picture of Mohit Chauhan Picture of Mohit Chauhan](/graphics/unknown.gif) Mohit Chauhan - 2009-02-16 08:24:41
hi,
I have used your code and it is working fine for forceDownload() function but for zip written to disk code is not working properly.i have used below code,
//-------------
include_once("createZip.class.php"); //save ur file as class file.
$createZip = new createZip;
$fileContents = file_get_contents("2am_60.aiff");
$createZip -> addFile($fileContents, "2am_60.aiff");
$fileName = "archive.zip";
$fd = fopen ($fileName, "wb");
$out = fwrite ($fd, $createZip -> getZippedfile());
fclose ($fd);
$createZip -> forceDownload($fileName);
//@unlink($fileName);
//------------------
when i try to unzip the file it shows me Unexpected end of archive or The archive is corrupt.CRC Failed in 2am_60.aiff.
Please help me in this.
actually i want a functionality that user browse multiple wav files using htmlfile control and it will wrapped up into 1 zip file and save to disk.
Thanks.
![Picture of Er. Rochak Chauhan Picture of Er. Rochak Chauhan](/picture/user/178944.png) Er. Rochak Chauhan - 2009-02-16 09:51:44 - In reply to message 1 from Mohit Chauhan
Hi Mohit.
Code seems to be fine, I guess the problem is with the memory allocation.
Check out your phpinfo() and look for memory_limit. This value would be your maximum file size (zip).
If you still face any issue, let me know.
Regards,
Rochak
![Picture of Mohit Chauhan Picture of Mohit Chauhan](/graphics/unknown.gif) Mohit Chauhan - 2009-02-17 04:57:35 - In reply to message 2 from Er. Rochak Chauhan
hi Rochak,
i have checked my phpinfo() file.
it shows me,
memory_limit 128M (for both Local Value and Master Value).
is it sufficient size or need to increase?
my maximum file size (zip) is created dynamically because i going add files dynamically through loop.
=========Also i have used below code using php inbuild function=====
// create object
$zip = new ZipArchive();
// open archive
if ($zip->open('file_download.zip', ZIPARCHIVE::CREATE) !== TRUE) {
die ("Could not open archive");
}
// Method 1 Manaually ..list of files to add
$fileList = array(
'Asian.wav',
'2am_30v1.wav',
'3.wav'
);
----> using Method1 manually to add files in array its working fine.add file,save and close the archive.
// Method 2 through loop ..list of files to add
$fileList = array();
for ($x = 1; $x <= 3; $x++){
$fileList[$x] = $_FILES['file'.$x]['name'];
}
----> using loop to add files in array not working.At the time of addfile function its give error. (ERROR: Could not add file: 2am_30v1.aiff)
// add files
foreach($fileList as $value)
{
$zip->addFile($value) or die ("ERROR: Could not add file: $value");
}
// close and save archive
$zip->close();
======================================================================
Please help me in this.
Thanks,
|