Welcome Guest, Not a member yet? Register   Sign In
Uploading Multiple Images
#3

[eluser]Kemik[/eluser]
Eeek this is working out harder than expected.

I can get the files to upload fine. However, handling errors and validation is more difficult. I'm trying to get it all in to one controller and view if possible. Especially in he view.

At the moment I have

Code:
function upload()
    {
        $this->load->helper('form');
        
        $this->load->view('includes/header');
        $this->load->view('gallery_upload', array('errors' => ''));
        $this->load->view('includes/footer');
    }
    
    function upload_process()
    {    
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';

        $this->load->library('upload');

        foreach($_FILES as $key => $value)
        {
            if (!empty($key['name'])) {
                $this->upload->initialize($config);

                if (!$this->upload->do_upload($key)) {
                    $errors[] = $this->upload->display_errors();
                    $this->load->view('gallery_upload', $errors);
                } else {
                    //$this->gallery_model->process_pic();
                    
                }
            }
        }
        $this->session->set_flashdata('green', 'The photos have been uploaded successfully.');
        redirect('gallery/upload');
    }

The problem is, I need to try and add some validation to the image upload fields. There is not set number at the moment but I could limit it to five if required. If I leave an upload field blank it brings back an error.

Has anyone made a multiple image upload form and have their controller and view to hand to give me some help please? Handling errors is a pain in the back side for this. I hate loops :p


Messages In This Thread
Uploading Multiple Images - by El Forum - 06-11-2008, 03:10 PM
Uploading Multiple Images - by El Forum - 06-12-2008, 01:15 AM
Uploading Multiple Images - by El Forum - 06-15-2008, 08:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB