Welcome Guest, Not a member yet? Register   Sign In
File Upload class
#3

[eluser]E303[/eluser]
Thanks for that.. Now I just get on error
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined index: file_name

Filename: admin/admin_model.php

Line Number: 234
Code:
function exhibitionsAddDB()
    {
        
        // dont need this line
        // $picture = $_FILES['userfile'];
        $url = url_title($_POST['title']);
        
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $this->upload->initialize($config);
        
        // dont pass in the value of userfile, do_upload retrieves the value of
        // userfile by default if no parameters are passed in.
        // If you pass in a paramter it looks for that field name in the post data
        // instead of userfile.
        // ALSO do upload only returns true or false if it succeded or not, not the file!
        if ( ! $this->upload->do_upload())
        {
            $error = $this->upload->display_errors();
            echo $error;
            return;
        }    
        else
        {
            $file_data = array('upload_data' => $this->upload->data());
            $data = array(
                        'title'            => $_POST['title'],
                        'description'    => $_POST['body'],
                        'date'            => $_POST['date'],
                        'endDate'        => $_POST['enddate'],
                        'artistId'        => $_POST['artist'],                
                        'url'            => $url,
                        'picture'        => $file_data['file_name'],
                    );
            $this->db->insert('exhibitions', $data);  
        }            
    }

Also when I look in the uploads file I don't see the file so I guess it doesn't get uploaded?


Messages In This Thread
File Upload class - by El Forum - 06-17-2008, 11:52 PM
File Upload class - by El Forum - 06-18-2008, 05:02 AM
File Upload class - by El Forum - 06-18-2008, 11:39 PM
File Upload class - by El Forum - 06-19-2008, 03:48 AM
File Upload class - by El Forum - 06-19-2008, 09:11 PM
File Upload class - by El Forum - 06-24-2008, 01:23 AM
File Upload class - by El Forum - 06-24-2008, 06:03 AM
File Upload class - by El Forum - 06-24-2008, 08:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB