Welcome Guest, Not a member yet? Register   Sign In
How do I remove requiring file selection ( File Uploading class issue)
#1

[eluser]barisv[/eluser]
Hi,

I have a form with several form_input and a form_upload. I am also doing some validations for inputs but I do not want user to select a file as an obligatory. If the user does not select a file, it says you did not select a file. It should be optional according to my scenario. Is there any way to do that ?

Thanks in advance.
#2

[eluser]Atharva[/eluser]
Do something like

Code:
if($_FILES['userfile']['name']!='')
        {


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


            $config['upload_path'] = './images/';
            $config['allowed_types'] = 'jpg|gif|png';
            $config['max_size'] = '10000';

            $this->upload->initialize($config);

            if ( ! $this->upload->do_upload()){
                    //display error
            }
            else
            {
                //insert into db
            }
        }
#3

[eluser]barisv[/eluser]
Thanks. This exactly what I needed.




Theme © iAndrew 2016 - Forum software by © MyBB