yosii Posted August 2, 2012 Share Posted August 2, 2012 this is my code <?php $zip = new ZipArchive(); $zip = new ZipArchive(); if($zip->open("C.zip",ZIPARCHIVE::CREATE)===TRUE) { $dir = scandir('test/'); $new_dir='test/'; $num=count($dir); for($k=0; $k<=$num; $k++) { if (@$dir[$k]!="." && @$dir[$k]!="" && @$dir[$k]!=".." && @$dir[$k]!="Thumbs.db") { $new_file=$new_dir.$dir[$k]; echo $new_file.'<BR>'; $zip->addFile($new_file); } } $zip->close(); $file = "C.zip"; header ("Content-Type: application/octet-stream"); header ("Accept-Ranges: bytes"); header ("Content-Length: ".filesize($file)); header ("Content-Disposition: attachment; filename=".$file); readfile($file); } ?> what i want is to download folder in rar and becuase of that i run FOR that read and add all my file to the function so.... it is download good and if i enter to the RAR file i see the file that in there...GOOD but when i tried to extract the file i get problem in RAR The archive is either in unknown format or damaged why???? if I do this code diffrend and choose file by file like <?php $zip = new ZipArchive(); $zip = new ZipArchive(); if($zip->open("S.zip",ZIPARCHIVE::CREATE)===TRUE) { $zip->addFile('test/1.GIF'); $zip->addFile('test/2.GIF'); $zip->addFile('test/3.GIF'); $zip->close(); $file = "S.zip"; header ("Content-Type: application/octet-stream"); header ("Accept-Ranges: bytes"); header ("Content-Length: ".filesize($file)); header ("Content-Disposition: attachment; filename=".$file); readfile($file); } ?> this work good that the problem in the FOR that run on all the folder that make problem when i extract the files.. thank Link to comment https://forums.phpfreaks.com/topic/266594-problem-with-extract-rar/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.