Hi everybody,
I try to insert a file in blob in my database. Using postgresql, I was following the wiki : http://www.yiiframework.com/wiki/95/saving-files-to-a-blob-field-in-the-database/ until the moment to save my data in my database.
First I got the error : "Uploaded File cannot be blank"
I had to add “‘htmlOptions’ => array(‘enctype’ => ‘multipart/form-data’)” in my _form widget (I don’t know if it was the best solution to solve it… but this error faded)
Then I got new error : " 7 ERROR: invalid byte sequence for encoding "UTF8": 0x89. The SQL statement executed was: INSERT INTO "up_down_test" ("file_name", "file_type", "file_size", "file_content") VALUES (:yp0, :yp1, :yp2, :yp3)"
But here, I’m stuck with this error doesn’t know what to do exactly… I followed the wiki so… I found this topic issue http://code.google.com/p/yii/issues/detail?id=102 but nothing helps me.
Are there any specificities on file I want to upload or anything else ??
except changes in wiki, I changed my rules() function such as :
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('','safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('uploadedFile', 'file', 'types'=>'jpg, gif, png','allowEmpty' => true),
array('','safe', 'on'=>'search'),
);
}
and my _form widget is :
<?php $form=$this->beginWidget('bootstrap.widgets.BootActiveForm',array(
'id'=>'up-down-test-form',
'enableAjaxValidation'=>false,
'htmlOptions' => array('enctype' => 'multipart/form-data')
)); ?>
and my table is :
CREATE TABLE up_down_test(id serial primary key,file_name text, file_type text,file_size bigint, file_content bytea)
If you have any ideas about this error…
thanks