How do I adjust this unzip script to place contenets in specific folder?

Posted on 2010-11-30
Last Modified: 2013-12-12
I have a simple script that works great on my server that unzips a file.  When the file is unzipped, it creates a new "folder" that is the same as the file name "CTG_product_photos".  I need the conents of the file to unzip in the "images" folder.  How do I fix this script to accomodate that?

<?php system('unzip'); ?>


<?php system('unzip'); ?>

Open in new window

Question by:rlb1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 56

Expert Comment

ID: 34241447
-d images

<?php system('unzip -d images'); ?>

Author Comment

ID: 34241506
Thanks for your help!  That worked.  However, it is still creating a new directory, CTG_product_photos, within the images directory.  Is there a way to eliminate the creation of the new directory and just dump the images in the 'image' directory?

LVL 56

Expert Comment

ID: 34242037
maybe this

<?php system('unzip images -d images'); ?>

is there any sample that you can post here (a test zip file containing a few images)
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.


Author Comment

ID: 34242171
OK, I used the code <?php system('unzip images -d images'); ?>
and the system returned "Archive:"

The path to the image folder is: /

I need the file to dump directly into the 'image' folder without creating a secondary folder.  

Please note: I changed 'images' to 'image' before running script.

I appreciate your help!!
LVL 56

Expert Comment

ID: 34242431
we need to know the inner structure of zip file... post a sample zip file, or open it with winzip (or some other tool and post screenshot of structure of zip file)

or lets try something else:

<?php system('unzip -x images -d images'); ?>
<?php system('mv CTG_product_photos\images images'); ?>

LVL 56

Accepted Solution

HainKurt earned 500 total points
ID: 34242511
ignore previous code

<?php system('unzip'); ?>
<?php system('mv CTG_product_photos\images images'); ?>

Author Closing Comment

ID: 34242666
Thank you for your help!!

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question