1
protected function _upload_file($id, $userfile, $folder, $thumb = TRUE)
{
if(empty($_FILES[$userfile]['name']) == TRUE)
{
return FALSE;
}
//altera nome do arquivo enviado
$_FILES[$userfile]['name'] = md5(uniqid()) . "." . pathinfo($_FILES[$userfile]['name'], PATHINFO_EXTENSION);
$this->load->library('Meu_upload');
$this->meu_upload->config['upload_path'] = './_tmp';
$this->meu_upload->config['overwrite'] = FALSE;
$this->meu_upload->config['allowed_types'] = "gif|jpg|jpeg|png|swf";
//enviando
if( $this->meu_upload->upload($userfile) == TRUE)
{
//salva referência em banco de dados
$file_save = $this->meu_upload->sucessUpload['file_name'];
//$this->model->save(array('imagem' => $this->meu_upload->sucessUpload['file_name']), $id);
//enviar para servidor remoto e remove da pasta tmp
$full_path = $this->meu_upload->sucessUpload['full_path'];
$url_save = $this->ClienteModel->get_url_save_image()."?folder=".$folder;
if($this->meu_upload->upload_remote_server($url_save, $full_path, $this->ClienteModel->get_token()) == FALSE){
exit("Erro upload remote server");
}
if($thumb == TRUE){
//redimensiona
if($this->meu_upload->resizeImage($this->altura_maxima, $this->largura_maxima, FALSE) === FALSE){
return FALSE;
}
//gera thumb da imagem
$this->meu_upload->execTrataImagem($this->altura_thumb, $this->largura_thumb, TRUE);
//enviar thumb para servidor remoto e remove da pasta tmp
if($this->meu_upload->upload_remote_server($url_save, $this->meu_upload->imagemResize, $this->ClienteModel->get_token()) == TRUE){
unlink($this->meu_upload->imagemResize);
}
}
//remove de pasta tmp
@unlink($full_path);
return $file_save;
}else
{
dbug($this->meu_upload->errorUpload);
return FALSE;
}
}
Explain the error, when it occurs, which line and what your goal is with this code
– Alexandre Cavaloti
Sorry for the call, when I try to upload an image the error "Error remote server" occurs in this section: if($this->meu_upload->upload_remote_server($url_save, $full_path, $this->Clientemodel->get_token()) == FALSE){ Exit("Remote Server Upload Error"); } This is an application made in 2010, in codeigniter 1.7, with the possibility of more metro, since yesterday analyzing and only now I found where the function that generates the error, but I don’t know what is causing, pq the only return is the string "Error upload remote server".
– Tiago Cardoso