Welcome Guest, Not a member yet? Register   Sign In
upload image using model/view/controller
#2

[eluser]Pascal Kriete[/eluser]
You need to upload it to a temporary spot on the disk first. Then you can do something like this:
Code:
// Get the image as 'text'
$image = file_get_contents('path/to/image.png');

$data = array(
    'name' => 'image.png',
    'contents' => $image
);

$this->db->insert('images', $data);

The contents field should be of the 'blob' or 'largeblob' type. Also, iirc file_get_contents reads the whole file into memory, so if you expect a lot of uploads you may want to consider creating a queue of sorts. And always check the file size to make sure you don't go over your memory limit.

Putting the file somewhere on the disk and just saving the path to the db is the solution I would use. It's faster.


Messages In This Thread
upload image using model/view/controller - by El Forum - 09-19-2008, 01:26 AM
upload image using model/view/controller - by El Forum - 09-19-2008, 08:05 AM
upload image using model/view/controller - by El Forum - 09-22-2008, 01:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB