CodeIgniter 1.7 Error upload remote server

0
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;
    }
}
    
asked by anonymous 06.10.2017 / 14:36

0 answers