Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

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

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
rlb1
Asked:
rlb1
  • 4
  • 3
1 Solution
 
HainKurtSr. System AnalystCommented:
http://linux.about.com/od/commands/l/blcmdl1_unzip.htm
-d images

<?php system('unzip CTG_product_photos.zip -d images'); ?>
 
0
 
rlb1Author Commented:
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
 
HainKurtSr. System AnalystCommented:
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
Technology Partners: 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!

 
rlb1Author Commented:
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
 
HainKurtSr. System AnalystCommented:
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
 
HainKurtSr. System AnalystCommented:
ignore previous code

<?php system('unzip CTG_product_photos.zip'); ?>
<?php system('mv CTG_product_photos\images images'); ?>
0
 
rlb1Author Commented:
Thank you for your help!!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now