BLOB images cut off
Posted: Sun Feb 01, 2009 11:42 pm
I have a script that uploads user submitted images for their profile image, the script works great minus the fact that it cuts the image off short.
The entire image is stored but the majority of it is just white space.
Here is the code that is doing the storing for me:
Anyone have a similar problem, or know what my problem might be?
The entire image is stored but the majority of it is just white space.
Here is the code that is doing the storing for me:
Code: Select all
if(is_uploaded_file($data['userfile']['tmp_name'])) {
// validate the image size
if($data['userfile']['size'] < $data['MAX_FILE_SIZE'])
{
// pull image contents from uploaded image
$imgData = chunk_split(base64_encode(file_get_contents($data['userfile']['tmp_name'])));
$sql = "INSERT INTO $this->table (name, content_type, contents, size) " .
"VALUES(" .
"'" . $data['userfile']['name'] . "', " .
"'" . $data['userfile']['type'] . "', " .
"'" . $imgData . "', " .
"'" . $data['userfile']['size'] . "')";
// run the query, pass false to avoid logging as the image data will make
// the log file's size too large over time
$this->db->query($sql, false);
return $this->db->insertId();
}
else {
throw new Exception("File exceeds the maximum size limit of " . $data['MAX_FILE_SIZE'] . ".");
}
}