application/libraries/MY_Upload.php
/**
	 * Initialize preferences
	 *
	 * $config = array(
	 * 		'document_root'			Absolute path. Root from where all other paths will be defined.
	 * 								No tampering to parent folder possible
	 * 								Cannot be send by the request
	 * 		'upload_path'			Relative path from the document_root in where the uploaded file will be stored
	 * 								Completes the document_root. No tampering to parent folder possible
	 * 								Cannot be send by the request
	 * 								Ionize : 'files/'
	 * 		'directory'				Relative path from '/document_root/upload_path/'
	 * 								Can be send by request.
	 * 								Overwritten by the do_upload() $config settings if it exists (to avoid user send)
	 * 								No tampering to parent folder possible
	 * 		'safe'					If set to TRUE, all file types will be allowed
	 * 								Else, only the extensions set in 'allowed_extensions' are allowed
	 * 		'allowed_extensions'	'*' : Allow all extensions
	 * 								Array : Array of allowed extensions
	 * 								Used by is_allowed_extension() if 'safe' = true
	 * 								and to prepare the file name : _prep_filename() (remove of the part extensions
	 * 		'clean_foreign_chars'	Set to TRUE, converts all foreign chars during the filename cleaning process
	 * 		'resize_image'			Resize the image to 'resize_width' and 'resize_height' if the file is one image
	 * 								'resize_width' and 'resize_height' must be set.
	 * 								The resize maintains image proportions.
	 * )
	 *
	 * @param	array
	 * @return	void
	 */
Initialize preferences
$config = array(
'document_root'                 Absolute path. Root from where all other paths will be defined.
No tampering to parent folder possible
Cannot be send by the request
'upload_path'                   Relative path from the document_root in where the uploaded file will be stored
Completes the document_root.

@param       array
@return      void
Initialize preferences $config = array ( ' document_root ' Absolute path . Root from where all other paths will be defined . No tampering to parent folder possible Cannot be send by the request ' upload_path ' Relative path from the document_root in where the uploaded file will be stored Completes the document_root . @param array @return void
public function initialize($config = array())
	{
		parent::initialize($config);
		$defaults = array(
			'safe' => FALSE,
			'clean_foreign_chars' => TRUE,
			'allowed_extensions' => array(),
			'document_root' => $_SERVER['DOCUMENT_ROOT'],
			'new_folder_chmod' => 0777,
			'resize_image' => FALSE,
			'resize_width' => 0,
			'resize_height' => 0,
		);
		foreach ($defaults as $key => $val)
		{
			if (isset($config[$key]))
			{
				$this->$key = $config[$key];
			}
			else
			{
				$this->$key = $val;
			}
		}
		if ($this->clean_foreign_chars)
		{
			$CI =& get_instance();
			$CI->load->helper('text');
		}
		$this->document_root = $this->normalize($this->document_root);
		$this->upload_path = $this->normalize($this->document_root . $this->upload_path);
		log_message('debug', 'MY_Upload initialized');
	}
public function initialize ( $ config = array ( ) ) { parent :: initialize ( $ config ) ; $ defaults = array ( 'safe' => FALSE , 'clean_foreign_chars' => TRUE , 'allowed_extensions' => array ( ) , 'document_root' => $ _SERVER [ 'DOCUMENT_ROOT' ] , 'new_folder_chmod' => 0777 , 'resize_image' => FALSE , 'resize_width' => 0 , 'resize_height' => 0 , ) ; foreach ( $ defaults as $ key => $ val ) { if ( isset ( $ config [ $ key ] ) ) { $ this -> $ key = $ config [ $ key ] ; } else { $ this -> $ key = $ val ; } } if ( $ this -> clean_foreign_chars ) { $ CI = & get_instance ( ) ; $ CI -> load -> helper ( 'text' ) ; } $ this -> document_root = $ this -> normalize ( $ this -> document_root ) ; $ this -> upload_path = $ this -> normalize ( $ this -> document_root . $ this -> upload_path ) ; log_message ( 'debug' , 'MY_Upload initialized' ) ; }
Initialize preferences
 $config = array(
              'document_root'                 Absolute path.
Initialize preferences $config = array ( ' document_root ' Absolute path .
// Foreign Chars : Text Helper // Sanitize of the upload path