Welcome Guest, Not a member yet? Register   Sign In
Hoe to check if a file is selected when postin a multipart form
#1

[eluser]Constantin Iliescu[/eluser]
Hello!

I have a form that sends data like name, email etc. and a file... But I don't know how to check if the a file is selected in my controller. Every time I want to change only the name or only the email, I get the message "You did not select a file to upload.".

Any ideas?

Thank you!
#2

[eluser]Constantin Iliescu[/eluser]
Never mind... It works Big Grin
#3

[eluser]Tracker[/eluser]
how do you solve this problem? i am getting same error "You did not select a file to upload."..
#4

[eluser]Constantin Iliescu[/eluser]
Code:
if ( ! $this->upload->do_upload())
            {
                $form_result['error'] = $this->upload->display_errors();
            }
            else
            {
                $file_info = $this->upload->data();
                
                $config['image_library'] = 'gd2';
                $config['source_image'] = './' . $images_path . $file_info['file_name'];
                $config['maintain_ratio'] = TRUE;
                $config['width'] = 259;
                //$config['height'] = 66;

                $this->load->library('image_lib', $config);

                if ($this->image_lib->resize())
                {
                    $page_data['image'] = $images_path . $file_info['file_name'];
                }
            }

Hope this helps.




Theme © iAndrew 2016 - Forum software by © MyBB