I would like to use the following class to resize my image before storing it on my server: https://www.verot.net/php_class_upload.htm?lang=en-GB
I have image data stored in a MySQL table encoded as base64.
So far I've gotten this far:
$data = $myBase64DataFromDb;
//if (preg_match('/^data:image\/(\w+);base64,/', $data, $type)) {
// $data = substr($data, strpos($data, ',') + 1);
// $type = strtolower($type[1]); // jpg, png, gif
// $data = base64_decode($data);
$path = '/img/put/here/';
// $filename = $data.'.'.$type;
// $handle = new upload($filename);
$handle = new upload($data);
$handle->file_max_size = '5000000';
$handle->image_resize = true;
$handle->image_x = 600;
$handle->image_ratio_y = true;
$handle->process($path);
if ($handle->processed) {
echo $filename;
$handle->clean();
} else {
echo 'error : ' . $handle->error;
}
// }
I keep getting error:
error : File not uploaded. Can't carry on a process.
What am I missing?