Solved

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

Posted on 2010-11-30
7
323 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
[X]
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
7 Comments
 
LVL 54

Expert Comment

by:Huseyin KAHRAMAN
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 54

Expert Comment

by:Huseyin KAHRAMAN
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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 

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 54

Expert Comment

by:Huseyin KAHRAMAN
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 54

Accepted Solution

by:
Huseyin KAHRAMAN 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.

729 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