insidus Posted June 9, 2012 Share Posted June 9, 2012 Scenario: I've got a form, which you use to ad multiple items of stock and for each item of stock, you can upload a zip file, which will contain 1 - "unlimited" amount of images. I need to be able to unzip the first file, then rename the images, then store them in a folder unique to that stock item, then do the same for every other stock item. So far, i've managed the uploading form, and can upload 1 zip file for each stock item, save it, and it is viewable on the server. However, i can't get the extracting to work. $files_uploaded = array(); for ($i = 0; $i < sizeof($_FILES['files']['name']); $i++) { $file = $i; $target_path = "image_processing/" . $file . '.zip'; move_uploaded_file($_FILES['files']['tmp_name'][$i], $target_path); array_push($files_uploaded, $target_path); } for($i = 0; $i < sizeof($files_uploaded); $i++) { echo $files_uploaded[$i] . " "; $zip = new ZipArchive(); $res = $zip->open($files_uploaded[$i]); if ($res === TRUE) { $zip->extractTo('image_processing/resizing/'); $zip->close(); echo " done "; } unset($zip); } This either seems to unzip all the files simultaneously, or just does the one, im not too sure. But it certainly doesn't do one file at a time. Thanks for any help, its highly appreciated! /insidus Quote Link to comment https://forums.phpfreaks.com/topic/263912-uploading-extracting-multiple-zip-files/ Share on other sites More sharing options...
.josh Posted June 9, 2012 Share Posted June 9, 2012 ...then store them in a folder unique to that stock item... $zip->extractTo('image_processing/resizing/'); I don't know what your "unique folder" naming convention is supposed to be but it should be implemented somewhere in that line of code...otherwise all your zips are being unzipped to that same folder. Quote Link to comment https://forums.phpfreaks.com/topic/263912-uploading-extracting-multiple-zip-files/#findComment-1352499 Share on other sites More sharing options...
insidus Posted June 9, 2012 Author Share Posted June 9, 2012 I wanted to unzip one file to that location, then the images are to be renamed, and then resized, then moved and the original images + zip file is deleted. Then the same happens with the next file. But it doesnt work Quote Link to comment https://forums.phpfreaks.com/topic/263912-uploading-extracting-multiple-zip-files/#findComment-1352531 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.