Solved

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

Posted on 2010-11-30
7
317 Views
Last Modified: 2013-12-12
Experts,
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 CTG_product_photos.zip'); ?>

Thanks!

<?php system('unzip CTG_product_photos.zip'); ?>

Open in new window

0
Comment
Question by:rlb1
  • 4
  • 3
7 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 34241447
http://linux.about.com/od/commands/l/blcmdl1_unzip.htm
-d images

<?php system('unzip CTG_product_photos.zip -d images'); ?>
 
0
 

Author Comment

by:rlb1
ID: 34241506
HainKurt,
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?

0
 
LVL 51

Expert Comment

by:HainKurt
ID: 34242037
maybe this

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

is there any sample that you can post here (a test zip file containing a few images)
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

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

The path to the image folder is: /www.myurl.net/web/content/cables/image

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!!
03170a.jpg
0
 
LVL 51

Expert Comment

by:HainKurt
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 CTG_product_photos.zip -x images -d images'); ?>
<?php system('mv CTG_product_photos\images images'); ?>



0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 34242511
ignore previous code

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

Author Closing Comment

by:rlb1
ID: 34242666
Thank you for your help!!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PHP Script - Am I missing anything here? 8 39
Button Click 11 26
html input clean up 3 32
Editing login page in zencart. 2 15
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now