Welcome Guest, Not a member yet? Register   Sign In
Only upload if user set a value
#1

[eluser]Corbee[/eluser]
Hi,

I'm doing a file upload, and I needed it to only upload if the user has set a value to the image.

I tried using

Code:
if ($this->input->post('logo'))
            {
                $config['upload_path'] = './images/CarLogo';
                $config['allowed_types'] = 'gif|jpg|png';
                $config['max_size']    = '100';
                $config['max_width']  = '180';
                $config['max_height']  = '180';
                $config['overwrite'] = 'TRUE';
                $this->load->library('upload', $config);
            
                if(!$this->upload->do_upload('logo'))
                {
                    $this->upload->display_errors();
                    exit();
                }
                    $logo = $this->upload->data();
                    
                if ($logo['file_name'])
                {
                    $logo = $logo['file_name'];
                    $this->MManage->updatelogo($logo);
                }
            }

but if you do an echo on the $this->input->post('logo');
you'll realize that it is always blank whether user sets it or not.

What's wrong with my code?

Thanks


Messages In This Thread
Only upload if user set a value - by El Forum - 10-10-2010, 09:05 PM
Only upload if user set a value - by El Forum - 10-10-2010, 09:52 PM
Only upload if user set a value - by El Forum - 10-11-2010, 07:39 AM
Only upload if user set a value - by El Forum - 10-12-2010, 07:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB