Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3361442
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:09:11+00:00 2026-05-18T03:09:11+00:00

This is my scenario: I upload a zip file Check each file in zip

  • 0

This is my scenario:

  • I upload a zip file
  • Check each file in zip file
  • If file != image, then move file to destination
  • if file == image, resize image and move to destination

I googled around and seen different solutions, but none where one can process files before saving them at the final destination.

This is the function I got so far:

  // Extract zip file and return files in an array. 
  private function processZip() {
    $zip = new ZipArchive;    
    $tmp_dir = FB_PLUGIN_DIR.'tmp/';

    // Extract files to 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.'*.*') as $filename) {

        // Somehow get MIME type here without using 'finfo' and 'mime_content_type'
        // I haven't installed PEAR and 'mime_content_type' is decapricated.
    }      

      return '1'; // success
    } else {
      return "0"; // fail
    } 
  } 

I’m not sure if I’m going in the right direction here. Somehow I think I should be able to process the files while in the “ZIP loop”.

Is there a way I can read the files in the ZIP file, determin the MIME type and then process file?

I found this example: http://www.java-samples.com/showtutorial.php?tutorialid=985
I think it’s close to what I need. But not sure what to modify.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:09:11+00:00Added an answer on May 18, 2026 at 3:09 am

    Decouple your processes. Extract everything from the ZIP file first, then scan the files for image files and process them.

    It’s a simpler process, and can be more easily decomposed for dealing with larger zipfiles.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would you test this scenario? I've just started looking into NHibernate and having
I have this scenario where I need data integrity in the physical database. For
we have this scenario: A server which contains needed data and client component which
I need to set up this scenario: A SQL Server 2005 database will create
This is a question for a WSS/SharePoint guru. Consider this scenario: I have an
How is it possible that .NET is finding the wrong MyType in this scenario?
I am trying to use JQuery in my ASP.Net 2.0 website in this scenario:
I'm still learning about REST and, in my test, came up with this scenario
I have this typical scenario. I have a smartclient application built on .net 2.0
The scenario is this We have two applications A and B, both which are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.