<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Upload_model extends MY_Model{
	function __construct(){
		parent::__construct();
	}
	
	function upload($field, $file_name="", $path="", $allowed_type=array(), $overwrite=TRUE){
		$error = "";
		
		$config['upload_path'] = "./assets/".$path;
		$config['allowed_types'] = implode("|", $allowed_type);
		$config['overwrite'] = $overwrite;
		if($file_name != "") $config['file_name'] = $file_name;
//		$config['max_size']	= "100";
//		$config['max_width'] = "1024";
//		$config['max_height'] = "768";

		$this->load->library("upload", $config);

		if(! $this->upload->do_upload($field)){
//			$error = $this->upload->display_errors('<p>', '</p>');
			$error = $this->upload->display_errors();
			$error = str_replace("<p>", "", $error);
			$error = str_replace("</p>", "", $error);
		}
		
		return $error;
	}
}