php - Need help processing a ZIP file -


this scenario:

  • i upload zip file
  • check each file in zip file
  • if file != image, move file destination
  • if file == image, resize image , move destination

i googled around , seen different solutions, none 1 can process files before saving them @ final destination.

this function got far:

  // extract zip file , return files in array.    private function processzip() {     $zip = new ziparchive;         $tmp_dir = fb_plugin_dir.'tmp/';      // extract files tmp dir     if ($zip->open($this->file['tmp_name']) === true) {       //check if temp dir exists. if not, create one.       if (!is_dir($tmp_dir)) {         mkdir($tmp_dir, 0700);       }        $zip->extractto($tmp_dir);       $zip->close();      /* process extracted files */       foreach(glob($tmp_dir.'*.*') $filename) {          // somehow mime type here without using 'finfo' , 'mime_content_type'         // haven't installed pear , 'mime_content_type' decapricated.     }              return '1'; // success     } else {       return "0"; // fail     }    }  

i'm not sure if i'm going in right direction here. somehow think should able process files while in "zip loop".

is there way can read files in zip file, determin mime type , process file?

i found example: http://www.java-samples.com/showtutorial.php?tutorialid=985
think it's close need. not sure modify.

decouple processes. extract zip file first, scan files image files , process them.

it's simpler process, , can more decomposed dealing larger zipfiles.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -