Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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

Posted on 2010-11-30
Medium Priority
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 59

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 59

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)
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


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 59

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 59

Accepted Solution

HainKurt earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

670 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