[eluser]gtech[/eluser]
I do a similar thing to upload into a MEDIUMBLOB, but couldn't get around it without uploading a file.. instead I delete (unlink) the file, after I gathered the content.
Step 1: I use the upload library to upload the file (read the documentation)
Step 2: after the call to do_upload() I read in the file, get the content, delete the file and then insert it into the database.
Code:
//read upload library documentation
....
....
$config['allowed_types'] = 'gif|jpg|png|mpg|wmv|mp3|wav';
$config['max_size'] = '16777215';
$config['max_width'] = '3000';
$config['max_height'] = '3000';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = $this->upload->display_errors();
$ret = array();
$ret['ErrorType'] = 2;
$ret['ErrorMessage'] = $error;
return $ret;
}
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);
// delete file
unlink($tmpName);
// now just insert $content into the database LONGBLOB. (remove slashes when reading in)
.....
.....
you have to ensure you database can handle longblobs as I had to change the mysql config to cope with this.