Reputation: 151
I'm trying to to upload image then resize it then appear error
"The path to the image is not correct.Your server does not support the GD function required to process this type of image." but in $config['source_image'] = './production/images/'.$id_akun.'jpg'; is my path from 'upload_path' => "./production/images/", so why my path is incorrect? this my function in controller
$id_akun=29;
$config = array(
'upload_path' => "./production/images/",
'allowed_types' => "jpg",
'file_name' => $id_akun,
'overwrite' => true,
'max_size' => "2048",
'max_height' => "768",
'max_width' => "1024"
);
$this->upload->initialize($config);
if($this->upload->do_upload('userfile'))
{
$data = array(
'id' => $id_akun,
'foto' => $this->upload->file_name
);
$this->User_model->upload($id_akun,$data);
$config['image_library'] = 'gd2';
$config['source_image'] = './production/images/'.$id_akun.'jpg';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 220;
$config['height'] = 220;
$config['create_thumb'] = TRUE;
$this->image_lib->clear();
$this->image_lib->initialize($config);
$this->image_lib->resize();
$er=$this->image_lib->display_errors();
echo json_encode($er);
exit();
}
Upvotes: 0
Views: 1443
Reputation: 850
GD is a php extension that handles image manipulation. The library you are loading requires it to work. GD: http://php.net/manual/en/book.image.php
If you don't have access to the server directly you're kinda out of luck unless you can get the hosting provider to provide the extension for you.
If you have the server and its on linux you can use the package manager to install it (as the root user, or use sudo)
CentOS / RHEL would be:
yum install php-gd
Ubuntu:
apt-get install php-gd
After installing these extensions you would need to restart your webserver to load the updated php.ini file.
Besides this, using ./
to start your path might not be helping, remove the .
at the start. I would also suggest ensuring the folder path exits from web-root and that you have the correct permissions set on the folder, if the server is linux and the webserver has ownership of the directory and files, ensuring you have the correct chmod set
Upvotes: 0