Welcome Guest, Not a member yet? Register   Sign In
Error: Cannot redeclare… using Unzip-library
#1

[eluser]Ornis[/eluser]
The following implemention of Unzip-library:

<?php
Class Unzip extends Controller {

function unzip() {
parent::controller() ;
}


function index() {
$this->load->library('Unzip');

// Give it one parameter and it will extract to the same folder
$this->unzip->extract('./img_maptiles/17.zip');

// or specify a destination directory
$this->unzip->extract('./img_maptiles/mydest/');

}
}

produces an error that I can't understand:

Fatal error: Cannot redeclare class Unzip in /home/httpd/vhosts/avimonitoring.ch/httpdocs/ci/system/application/libraries/Unzip.php on line 22

What do I miss here? Thanks for your help.

Martin
#2

[eluser]WanWizard[/eluser]
All CI classes run in the same namespace. A controller, a model, a library, they're all classes. So you can't have a controller with the same name as a library (or a model).
#3

[eluser]Ornis[/eluser]
Thanks! How could I miss this… Embarrassing!
#4

[eluser]jur[/eluser]
hi, i just follow the usage of unzip library but nothing happens.

i pass a full path parameter like this:
$path = 'C:/Users/Jur/Xampp/xampp/htdocs/website/css/themes/default.zip'

// Give it one parameter and it will extract to the same folder
$this->unzip->extract($path);

the library successfully loaded and the file_open can read my zip file.

is there something wrong with my path.? thanks
#5

[eluser]Ornis[/eluser]
Probably. You must provide the base-path. It's possible that the base-path differs from the folder-path (I am not a Windows/XAMPP-user) or you may use backslahes instead of forwardslashes.
#6

[eluser]Cristian Gilè[/eluser]
On Windows, both slash (/) and backslash (\) are used as directory separator character. In other environments, it is the forward slash (/).

Unzip class requires extension ZLib enabled. Have you enabled it?


Cristian Gilè
#7

[eluser]jur[/eluser]
Hi Ornis and Cristian Gile, Thanks for your reply!

Through some trial and error, i discovered that theres nothing wrong in my path,my ZLib enabled, the unzip class is functioning well.

the problem is, I have a directory named 'default' on my target path so when the default.zip extracted, it will replace the default directory that existed. thats why I imagine theres nothing happen when i call the $this->unzip->extract($path);

Next time ill be more carefull.. haha, once again thank you very much! Smile




Theme © iAndrew 2016 - Forum software by © MyBB