primetechv2 Posted May 8, 2008 Share Posted May 8, 2008 I want to take an array of files, retrieve them via CURL, and then compress them into a ZIP archive. Unfortunately, PHP has different plans and creates zip files that are unreadable. $files = $_POST['files']; $files = explode( "\n" , $files ); $zip = new ZipArchive(); $filename = "./test112.zip"; unlink($filename); // delete it if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) { exit("cannot open <$filename>\n"); } for ($i = 0; $i < sizeOf($files); $i++) { $files[$i] = str_replace( "\l", "", $files[$i] ); $files[$i] = str_replace( "\n", "", $files[$i] ); $files[$i] = str_replace( "\r", "", $files[$i] ); $files[$i] = str_replace( " ", "", $files[$i] ); if ($files[$i] != "") { echo "Adding " . $files[$i] . "<br>\n"; $out = geturl( $files[$i] ); // $addfile = fopen("$i.tmp",'w'); // fwrite($addfile, $out); // fclose($addfile); $zip->addFromString("$i.tmp",$out); //echo "<textarea cols=30 rows=20>" . $out . "</textarea><br>\n"; } } Link to comment https://forums.phpfreaks.com/topic/104733-php-zip-creating-grief/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.