[eluser]Rubiz'[/eluser]
Hi there!
I'm trying to make my upload class something as a helper, than I can config it dynamically cause I have several forms and I have audio extensions, video extensions, ppt, pdf, and images.
I tried to take the exemple used in user guide and make a helper, but it returns me an error about $this used in wrong place.
Now, I have it:
Code:
<?
class Upload extends Controller {
function Upload()
{
parent::Controller();
}
function do_upload($path, $maxWidth = NULL, $maxHeight = NULL)
{
$config['upload_path'] = $path;
$config['allowed_types'] = 'jpg|gif|png|bmp|ppt|pps|pdf';
$config['max_size'] = '10000';
$config['max_width'] = $maxWidth;
$config['max_height'] = $maxHeight;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
echo $error;
}
else
{
$data = array('upload_data' => $this->upload->data());
echo $data['file_name'];
}
}
}
?>
I'd like to know how I can become this dinamic... to use as a method... ?
And, when I have a pdf file or ppt file, I dont need to specify width and height, this NULL I have used is right if I have no dimensions?