Welcome Guest, Not a member yet? Register   Sign In
Upload pic's problem
#1

[eluser]Unknown[/eluser]
Hi guys im new on the codeigniter world so may be this is not a big problem for some of you but im stock with this.
I'm developing a blog just to start and learn the basic concepts of CI. I based on the videotutorials from here but i add a plus i whant to upload a picture on the entries and here is my problem

Code:
<?php  
class Upload extends CI_Controller{
    
    function Upload(){
    parent::__construct();
    $this->load->helper(array('form','url'));
    }
    function insert_entri()
    {
            $pageiinfo['upload_path']='./uploads/';
            $pageiinfo['allowed_types']='gif|jpg|png';
            $pageiinfo['max_size']='1000';
            $this->load->library('upload',$pageiinfo);
                
            //on the next line i have my error CI says to me Call to undefined method CI_Upload::insert_entri()
                if(! $this->upload->insert_entri()){
                    $error = array('error'=> $this->upload->display_errors());
                    $this->load->view ('viewaddentri', $error);
                }
                    else{
                        $pageiinfo = array('upload_data' => $this->upload->data());
                        $this->load->view('upload_echo',$pageiinfo);
                    }
        
    }
}
?>
im not asking for some body do my job just i want an explanation be cause im goin to be nuts if some body doesnt help me please

so thanks so much and i hope some body can help these young developer.
#2

[eluser]cideveloper[/eluser]
1) PHP 5 constructor problem
2) go through the upload library docs

There is no function insert_entri() in the upload class. Its a little bit confusing in the docs cause they name the controllers and the library functions the same thing.

Code:
<?php  
class Upload extends CI_Controller{
    
    function __construct(){
       parent::__construct();
       $this->load->helper(array('form','url'));
    }
    function insert_entri()
    {
            $pageiinfo['upload_path']='./uploads/';
            $pageiinfo['allowed_types']='gif|jpg|png';
            $pageiinfo['max_size']='1000';
            $this->load->library('upload',$pageiinfo);
                
                if(! $this->upload->do_upload()){
                    $error = array('error'=> $this->upload->display_errors());
                    $this->load->view ('viewaddentri', $error);
                }
                    else{
                        $pageiinfo = array('upload_data' => $this->upload->data());
                        $this->load->view('upload_echo',$pageiinfo);
                    }
        
    }
}
?>
#3

[eluser]Unknown[/eluser]
ok! now i have more clearly some things do_upload is the name of the function on the class upload i thougt it was the name that i was using.
thanks so much, the problem i solved but more errors still appear im going to try of solv them but if i cant im going to ask again thak you @cideveloper




Theme © iAndrew 2016 - Forum software by © MyBB