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 7782761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:38:30+00:00 2026-06-01T19:38:30+00:00

I have a zip file that i must update an file under a folder

  • 0

I have a zip file that i must update an file under a folder , the following block works “well”, it add correctly the file node.ndf under the path specified.

But if i run it for the second time or more , it duplicates the file under the folder

as example:


first time run:

file.zip content:

manifest.v3

ns/adapt/node.ndf


second time run:

manifest.v3

ns/adapt/node.ndf

ns/adapt/node.ndf


and so on…

Here is the code im currently using:

$obj = Archive::Zip->new();  

$status = $obj->read($file); 

if ($status != AZ_OK) {
die('Error in file!');
    } else {
        @files = ('node.ndf');

       foreach $filea (@files) {
    $obj->addFile($filea); 
    $obj->addTreeMatching( '.', 'ns/adapt/', 'node.ndf' );
   }

   if ($obj->overwrite() != AZ_OK) {  
    print "Error in archive creation!";
    exit;

    } else {
    print "Archive created successfully!";
    }
unlink('node.ndf');
 }

Anyone know the correct usage of Archive::Zip in order to update a file under a folder structure at the zip file?

Thanks in advance.

  • 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-06-01T19:38:32+00:00Added an answer on June 1, 2026 at 7:38 pm

    You can either

    $obj->removeMember('ns/adapt/node.ndf');
    $obj->addFile('node.ndf', 'ns/adapt/node.ndf');
    

    or, if your node.ndf file has changed size or modification time, you can do both in a single step with

    $obj->updateMember('ns/adapt/node.ndf', 'node.ndf');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a zip file that contains folder hierarchies and files. \images\ \images\1.jpg \images\2.jpg
I have several large zip file that contain a dir structure that I must
I have found that creating a zip file using the Zip task provided by
I have a file that contains a mish-mash of cities, states, and zip codes.
I have a ZIP archive that's embedded inside a larger file. I know the
I have a small job that takes a text file of email/zip codes and
I have a zip file containing a folder structure like main-folder/ subFolder1/ subFolder2/ subFolder3/
I have a form where the user can upload a zip file, it works
I have a .zip file that contains sub-directories with html,png, and css files in
I cannot use third party software/libraries and have a zip file that I have

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.