1
votes

Gd2 is also enabled. Tried many ways... Don't know what's wrong

A PHP Error was encountered Severity: Notice Message: getimagesize(): Read error! Filename: libraries/Image_lib.php Line Number: 1651

Backtrace: File: /opt/lampp/htdocs/ciflix/application/controllers/Admin.php Line: 52 Function: library File: /opt/lampp/htdocs/ciflix/index.php Line: 315

Function: require_once


The provided image is not valid.

Your server does not support the GD function required to process this type of image.

$config['upload_path'] = $path;
$config['allowed_types'] = $allowed_types;
$config['max_size'] = 15000;
$config['max_width'] = 1024;
$config['max_height'] = 768;

$this->load->library('upload', $config);

if(!$this->upload->do_upload('userfile')){
    $this->session->set_flashdata('file_error', $this->upload->display_errors());
    redirect('admin/create_blog');
}else{
    $data = $this->upload->data('userfile');
    $config['image_library'] = 'gd2';
    $config['source_image'] = $path.$data['userfile'];
    $config['create_thumb'] = FALSE;
    $config['maintain_ratio'] = FALSE;
    $config['width'] = 200;
    $config['height'] = 200;
    $config['new_image'] = $path.$data['userfile'];
    $this->load->library('image_lib', $config);

    if(!$this->image_lib->resize()){
        echo $this->image_lib->display_errors();
        exit();
    } else {
        echo "Working";
        exit();
    }

    $post_image = $_FILES['userfile']['name'];
}
4
You should enable GD extension from php.ini - Pankaj Makwana
did you restart apache2? - Shanu k k
Did but didn't work extension=php_gd2.dll - flixy
yes. restarted. - flixy
is it okie now? - Shanu k k

4 Answers

1
votes

You need to install the GD extension. If it is already installed, edit your php.ini to enable it (delete the ; to not make it a comment ).

If it isn't installed, try this:

apt-get install php5-gd

EDIT:

I just noticed you mentioned a .dll. That's for Windows! Comment iut out, enable the extension gd.so, and restart the server, see if that helps!

0
votes

Please try this

sudo apt-get install php5-gd

or

apt-get install --reinstall php5.0-gd

then restart apache

 sudo service apache2 restart

OR enable the library GD2 from php.ini file remove semicolon from ;extension=php_gd2.dll

Check GD is enabled or not using the following command

$ php -i | grep -i --color gd 

You can also test using php code.create a php file using the following code and run and check the GD extension is enabled or not

<?php
  phpinfo();
?>
0
votes

During my project I faced similar problem. This link help me to solve it.

Replace

$this->load->library('image_lib', $config);

with

$this->load->library('image_lib');
// Set your config up
$this->image_lib->initialize($config);
// Do your manipulation
$this->image_lib->clear();
-1
votes

If you are on a local server like XAMPP, you probably have Port 80 being used by another application.

XAMPP Control Panel v3.2.4