[eluser]Rubiz'[/eluser]
Hi there, I'll be so much happy when I have no doubts about any futures of code igniter :-)
Well, I have problems, now, with uploading files...
I wrote a helper cause I have several types of upload to do, swf, pdf, ppt, mp3...
In my helpers folder I have:
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function enviar ($caminho, $ext, $tam, $larg, $alt, $nome_campo)
{
$config['upload_path'] = $caminho;
$config['allowed_types'] = $ext;
$config['max_size'] = $tam;
$config['max_width'] = $larg;
$config['max_height'] = $alt;
$this->load->library('upload', $config);
if ( $this->upload->do_upload($nome_campo) ) return $this->upload->data('file_name');
else $this->upload->display_errors();
}
?>
in my controller...
Code:
if (!empty($_FILES['thumb_plantas']['name'][0]))
{
$tipo = 'plantas';
// upload de img ===============================================================================================================
$caminhoImg_plantas = 'http://www.villabranca.com.br/imgs/upload/' . $sessao . '/' . $subsessao . '/' . $tipo . '/';
$caminhoThumb_plantas = 'http://www.villabranca.com.br/imgs/upload/' . $sessao . '/' . $subsessao . '/' . $tipo . '/thumbs/';
for ($i=0; $i < $countPlantas; $i++)
{
$img = $this->helpers->uploading->enviar($caminhoImg_plantas, 'gif|jpg|png', '500', '776', '420', 'img_plantas' . $i);
$thumb = $this->helpers->uploading->enviar($caminhoThumb_plantas, 'gif|jpg|png', '50', '120', '120', 'thumb_plantas' . $i);
}
if ($this->Imovel_model->adicionar($sessao, $nome_sessao, $subsessao, $nome_subsessao, $tipo, $img, $thumb, $legenda))
{
$nome_usuario = $this->session->userdata('us');
$status['user'] = $nome_usuario;
$status['status'] = 'sucesso';
$this->load->view('status', $status);
}
else
{
$nome_usuario = $this->session->userdata('us');
$status['user'] = $nome_usuario;
$status['status'] = 'erro';
$this->load->view('status', $status);
}
}
I set up permissions in all folders properties...
I'm calling the helper right?
Is my logic illogical?
I get a blank page as return...