Page 1 of 1

Unzip Problem

Posted: Fri Mar 30, 2012 5:24 am
by TeeTwo
I am uploading a zip file and a created unzip file to use and I am having the extractTo statement creating the folders. I wish to unzip in the same folder as the unzip script. It works ok only creates the folders Public_html/Test
My code

Code: Select all

<?php
$zip = new ZipArchive;
$res = $zip->open('Decision.zip');
if ($res == TRUE) {
$zip->extractTo('public_html/Test');
$zip->close();
echo "ok";
} else {
echo "failed";
     }
?>


Re: Unzip Problem

Posted: Fri Mar 30, 2012 6:55 am
by social_experiment
TeeTwo wrote:I wish to unzip in the same folder as the unzip script.
where is the script located

Re: Unzip Problem

Posted: Fri Mar 30, 2012 4:39 pm
by TeeTwo
Thanks for reply. The script is in Public_html/Test. In Test but when I run script it also creates Public_html/Test off the previous Test folder. I wish to extract to the original Test folder without creating more folders

Re: Unzip Problem

Posted: Fri Mar 30, 2012 5:59 pm
by social_experiment
the directory i tested it in is called 31032012; by using the path below it extracted in the same directory as the zip file

Code: Select all

<?php
$zip->extractTo('../31032012');
?>

Re: Unzip Problem

Posted: Fri Mar 30, 2012 10:06 pm
by TeeTwo
Thanks for help. I did discover this. but no explanation it was in another script
$zip->extractTo(dirname(_File_');

This seems to work but I will note what you have.

Re: Unzip Problem

Posted: Sun Apr 01, 2012 2:42 am
by social_experiment
I think the option that you have is a better one; more generic so that you don't have to change the directory (in the script) each time you use the script elsewhere

Re: Unzip Problem

Posted: Sun Apr 01, 2012 7:27 am
by TeeTwo
This is what I write with my program I created to upload zip files. Strange I had no trouble getting the files to any server, I could dump them in the set directory but it created additional folders. Still this works

Code: Select all

<?php
$zip = new ZipArchive;
$res = $zip->open('Zip.zip');
if ($res === TRUE) {
$zip->extractTo(dirname(_File_));//<<<The answer, easy when you knoe
$zip->close();
echo "OK > Uploaded and Extracted";
} else {
echo "failed";
     }
?>
The zip file and Unzipper is in the upload folder.
I create web pages, most with forms and I use Coffee Cups Web Form Builder as it is a no brainer I do not have to line stuff up etc. anyway it creates a folder with about 80 files. Takes forever by normal ftp so I zip it up, serve it up and extract.
I use Rapidq, hasn't the overhead of VB. Got it to connect upload and extract in 15secs. That is good on Aussie Broad Band

Re: Unzip Problem

Posted: Mon Apr 02, 2012 8:09 am
by TeeTwo
Got it finished Trial here if anyone wants a copy http://zipupextract.comze.com