EllisLab text mark
Advanced Search
     
how to use the class.upload.php as a library?
Posted: 29 April 2008 07:57 PM
Joined: 2008-04-25
58 posts

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…

 Signature 

a beaultiful application built w/ CodeIgniter

 
Posted: 02 May 2008 04:28 AM   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-06-14
37 posts

Hi, welcome! CI includes it’s own file upload library which you should try first. See the documentation for it here.

Good Luck!

 Signature 

Ben McRedmond,
Awesome CI Pastebin

 
Posted: 02 May 2008 07:55 AM   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-27
198 posts

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….

 
Posted: 02 May 2008 08:00 AM   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-10
2937 posts

You can use library constructor parameters

$this->load->library('some_library'$params); 
 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

 
Posted: 02 May 2008 08:05 AM   [ # 4 ]   [ Rating: 0 ]
Joined: 2007-06-14
37 posts
wiredesignz - 02 May 2008 12:00 PM

You can use library constructor parameters

$this->load->library('some_library'$params); 

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

 Signature 

Ben McRedmond,
Awesome CI Pastebin

 
Posted: 02 May 2008 08:40 AM   [ # 5 ]   [ Rating: 0 ]
Joined: 2008-04-25
58 posts

thnaks…
I"ll try and come back to say what happened

 Signature 

a beaultiful application built w/ CodeIgniter

 
Posted: 02 May 2008 08:52 AM   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-27
198 posts

uh, thanks for the lesson, gentlemen!!
I didn´t know that its possible to pass parameters tongue wink

 
Posted: 13 January 2011 09:49 AM   [ # 7 ]   [ Rating: 0 ]
Joined: 2011-01-13
2 posts

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

 
Posted: 17 January 2011 06:17 AM   [ # 8 ]   [ Rating: 0 ]
Joined: 2008-04-25
58 posts

1. Copy the folder class.upload to libraries directory;

2. Create a new library with this 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:

$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);
.... 
 Signature 

a beaultiful application built w/ CodeIgniter

 
Posted: 17 January 2011 10:51 AM   [ # 9 ]   [ Rating: 0 ]
Joined: 2011-01-13
2 posts

thanks got it working.