Hi,
I have create one form, when the user upload the image to SQLite database
Image stored in databse, not the server!
Two problem.
1./ Image resize without save
Code:
$x_file = $this->request->getFile('file');
$image = \Config\Services::image()
->withFile($x_file)
->resize(300, 300, true, 'height')
->save(WRITEPATH .'uploads/'. $x_file->getRandomName());
I have only Image object, which store in database blob field. I probe without save only resize(..); but its wrong!
2./ Database image write error
Code:
$fileData = [
'Name' => 'Nev',
'Desc' => 'Valami',
'Quantity' => 2,
'Image' => new RawSQL(file_get_contents(WRITEPATH .'uploads/'. $xName))
];
$store = $db->table('Product')->insert($fileData);
Error message:
SQLite3::exec(): incomplete input
If I change the code:
Code:
'Image' =addslashes(file_get_contents(WRITEPATH .'uploads/'. $xName))
The upload is Ok, but the table in BLOB field in binary string not the image: ff d8 ff e0 ...
If I change the code:
Code:
'Image' = file_get_contents(WRITEPATH .'uploads/'. $xName)
The upload is Ok, but the BLOBL filed only 4 characters (ff d8 ff e0)
Thanks a lot!