Welcome Guest, Not a member yet? Register   Sign In
how to use the class.upload.php as a library?
#1

[eluser]Jônatan fróes[/eluser]
i'm new in CI so i'd like to use the class.upload ( see the class page here )

does someone could help me?

sorry for my 'brazilian' english...
#2

[eluser]benofsky[/eluser]
Hi, welcome! CI includes it's own file upload library which you should try first. See the documentation for it here.

Good Luck!
#3

[eluser]gunter[/eluser]
you can include the class with include().... if you want...
or you can make a library out of it, but thats a little bit more difficult,
because in a CI library you cannot use constructor parameters....
#4

[eluser]wiredesignz[/eluser]
You can use library constructor parameters
Code:
$this->load->library('some_library', $params);
#5

[eluser]benofsky[/eluser]
[quote author="wiredesignz" date="1209744058"]You can use library constructor parameters
Code:
$this->load->library('some_library', $params);
[/quote]

If you still want to use your class, put it on /system/application/libraries and you can load it like above.
#6

[eluser]Jônatan fróes[/eluser]
thnaks...
I"ll try and come back to say what happened
#7

[eluser]gunter[/eluser]
uh, thanks for the lesson, gentlemen!!
I didn´t know that its possible to pass parameters ;-P
#8

[eluser]Patrikk[/eluser]
Hi everyone,

my first post here and I would also like to use the class.upload instead of the built in one.

Ive been reading this thread but need some more help to pull this off.
Ive done the following:

* added the class.upload in libraries folder.

* made a controller called upload and a view called upload also.

* loaded the class.upoload in the controller like it was suggested here
( $this->load->library('class.upload'); )

My problem is:
I get the following error message: Fatal error: Cannot redeclare class upload in ...\system\application\libraries\class.upload.php on line 550

what am I missing as very new with CI so I need help from the experts on this forum.

thx all help that I get
#9

[eluser]Jônatan fróes[/eluser]
1. Copy the folder class.upload to libraries directory;

2. Create a new library with this code:
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Imaging Class
*
* A port of the class.upload.php by Colin Verot to allow you to use
* the functionality of the class through CI as a library. You can
* watermark, resize, crop all in a very memory efficient manner.
*
* Using this class instead of the CI image_lib class because it has
* better file support for PNG or GIF especially when transparent.
*
*/

// Include the main class
require_once(APPPATH.'libraries/class.upload/class.upload.php');

// Extend it
class Imaging extends upload {

    function Imaging() {
        log_message('debug', get_class($this).' Class Initialized');
    }
    
}
// END Imaging Class

/* End of file Imaging.php */
/* Location: ./system/application/libraries/Imaging.php */

3. Now, in your controller, use this:


Code:
$this->load->library('imaging');

if($this->imaging->uploaded)
{

    $this->imaging->mime_check = TRUE;
    $this->imaging->allowed = array('image/*');
    $this->imaging->file_new_name_body = $nome;
    $this->imaging->process($path);
....
#10

[eluser]Patrikk[/eluser]
thanks got it working.




Theme © iAndrew 2016 - Forum software by © MyBB