Welcome Guest, Not a member yet? Register   Sign In
Problem with file upload on edit page
#1

[eluser]opel[/eluser]
I have been working on a cms for a small site and having a problem with the edit page and file upload.

My edit page shows the currently uploaded file and option to upload a new file. THe problem occurs if I submit an edit page without a putting a new file in the "file" field as it tried to do the upload in the model even though I have put if not null. My code is below, could anyone advise where I am going wrong please ?

THanks

Code:
function update()
    {    
    

    
      $content = array('title' => $_POST['title'],
                      'category' => $_POST['category'],
                    'description' => $_POST['description'],
                  'order' => $_POST['order']);
    
    if ($_FILES['myfile'] != NULL)
    {
        $config['upload_path'] = './includes/uploads/';
        $config['allowed_types'] = 'gif|jpg';
        $config['max_size'] = '1000';
        $config['remove_spaces'] = true;
        $config['overwrite'] = true;
        //$config['max_width']  = '400';
        //$config['max_height']  = '400';
        $this->load->library('upload', $config);    
        
        if( ! $this->upload->do_upload('myfile'))
        {
            echo $this->upload->display_errors();
            exit();
        } else
        {
        
            // Thumbnail
            $data = array('upload_data' => $this->upload->data());
          $temp=$this->upload->data();
          
          $thumb['image_library'] = 'GD2';
          $thumb['source_image'] = './includes/uploads/'.$temp['file_name'];
          $thumb['new_image'] = './includes/uploads/thumb/'.$temp['file_name'];
          $thumb['maintain_ratio'] = TRUE;
          $thumb['create_thumb'] = TRUE;
          $thumb['quality'] = '100';
          $thumb['height'] = '80';
          $thumb['width'] = '80';
      
          $this->load->library('image_lib', $thumb);
          $this->image_lib->resize();
          
           //making a thumbnail
            $this->image_lib->clear();
            
            //insert to the DB


            $content['file'] = $temp['file_name'];


        }

        $this->db->where('id', $_POST['id']);
        $this->db->update($this->table, $content);
      }


    }


Messages In This Thread
Problem with file upload on edit page - by El Forum - 11-12-2008, 04:40 PM
Problem with file upload on edit page - by El Forum - 11-13-2008, 10:45 AM
Problem with file upload on edit page - by El Forum - 11-13-2008, 03:22 PM
Problem with file upload on edit page - by El Forum - 11-14-2008, 03:00 AM
Problem with file upload on edit page - by El Forum - 11-14-2008, 05:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB