Welcome Guest, Not a member yet? Register   Sign In
File upload to database
#3

[eluser]junaids[/eluser]
i followed this thred
http://ellislab.com/forums/viewthread/81832/

and got into an error. my code is like this
Code:
function do_upload()
    {
        $config['upload_path'] = './profile_imgs/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '1000';
        $config['max_width']  = '0';
        $config['overwrite']  = FALSE;
        $config['remove_spaces']  = TRUE;
        $field_name = "file_name";
        
        $this->load->library('upload', $config);
        
         if ( ! $this->upload->do_upload($field_name))
        {
            $error = array('error' => $this->upload->display_errors());
            $this->load->view('profileimage', $error);
        }    
        else
        {
          $data = array('upload_data' => $this->upload->data());
          $tmpName  = $data['upload_data']['full_path'];
                 $fileSize = $data['upload_data']['file_size'];

             $fp      = fopen($tmpName, 'r');
                 $content = fread($fp, filesize($tmpName));
                 $content = addslashes($content);
         fclose($fp);
         unlink($tmpName);
         $content = stripslashes($content);
         $this->db->where('user_id', '2');
         $this->db->update('user', $content);
        }
    }

the error is
Error Number: 1300

Invalid utf8 character string: '‰PNG'

UPDATE `user` SET ‰PNG...and a large string of characters.
the file is uploaded to the specified path. but its not updated in the Db.
any idea about the error!


Messages In This Thread
File upload to database - by El Forum - 05-09-2009, 11:26 PM
File upload to database - by El Forum - 05-10-2009, 12:23 AM
File upload to database - by El Forum - 05-10-2009, 03:04 AM
File upload to database - by El Forum - 05-10-2009, 04:42 AM
File upload to database - by El Forum - 05-10-2009, 04:46 AM
File upload to database - by El Forum - 05-10-2009, 08:32 AM
File upload to database - by El Forum - 05-10-2009, 09:08 AM
File upload to database - by El Forum - 05-10-2009, 09:18 AM
File upload to database - by El Forum - 05-10-2009, 09:44 AM
File upload to database - by El Forum - 05-10-2009, 09:46 AM
File upload to database - by El Forum - 05-10-2009, 09:51 AM
File upload to database - by El Forum - 05-10-2009, 10:01 AM
File upload to database - by El Forum - 05-10-2009, 11:58 AM
File upload to database - by El Forum - 05-10-2009, 02:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB