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
Solved

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

Posted on 2010-11-30
7
320 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Couls you point a way to make Codeigniter to consider the UTF-8 characters in config.php? 14 74
Cookie not unsetting 7 27
XML extra information 8 29
JQuery Search Filter 2 32
This article discusses how to create an extensible mechanism for linked drop downs.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

829 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