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

Is there some open source file upload (application) solution for a scenario like this?
i'm struggling around for days now ...this is the scenario: a user can upload
the scenario needs to run like this: client uploads CSV file which then dynamically
Imagine this scenario: in our company there is an employee that play around graphic,css,html
Consider this scenario: I've an XML file called person.xml with the following data in
I have a scenario where users can upload an image, OR a video (from
Scenario A image website that has basic features such as upload, comment, like, follow
My scenario is a users table and a pictures table. Each user can upload
I have to check the Content of a zip/rar file before uploading to the
Image this scenario: There is a picture locally in my server, where a sketch

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.