Welcome Guest, Not a member yet? Register   Sign In
Check to see if there is a file to upload
#1

[eluser]jake142[/eluser]
Hi,

Im new to codeigniter (and new to php). How can I check if there is a file to upload, befor I do the actual upload? The $this->input->post('userfile')!="" doesn't work.

Code:
if($this->input->post('userfile')!="")
        {
            if ( ! $this->upload->do_upload())
            {
                $error = array('error' => $this->upload->display_errors());
                $this->load->view('header');
                $this->load->view('ads/error', $error);
                $this->load->view('right_side');
                $this->load->view('footer');
            }
            else
            {
                $data = array('upload_data' => $this->upload->data());
                $upload_data = $data['upload_data'];

                $config['image_library'] = 'gd2';
                $config['source_image'] = $upload_data['full_path'];

                $config['maintain_ratio'] = TRUE;
                $config['width'] = 300;
                $config['height'] = 300;
                $this->load->library('image_lib', $config);
                $this->image_lib->resize();
                $this->image_lib->clear();
                $imagename = $upload_data['file_name'];
                $contenttype = $upload_data['file_type'];
            }
        }
        else
        {
            //Just store some information in db and use default file (always uploaded)
        }

Any help is very appritiated.

Thanks!


Messages In This Thread
Check to see if there is a file to upload - by El Forum - 12-06-2009, 03:31 AM
Check to see if there is a file to upload - by El Forum - 12-06-2009, 06:02 AM
Check to see if there is a file to upload - by El Forum - 12-06-2009, 07:13 AM
Check to see if there is a file to upload - by El Forum - 12-06-2009, 07:28 AM
Check to see if there is a file to upload - by El Forum - 12-06-2009, 07:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB