1

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'];
}
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
flixy
  • 73
  • 2
  • 10

4 Answers4

1

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!

delboy1978uk
  • 12,118
  • 2
  • 21
  • 39
  • I just noticed you mentioned a `.dll`. That's for Windows! Comment iut out, enable the extension that ends in `.so`, and restart the server, see if that helps! – delboy1978uk Sep 14 '17 at 11:14
  • Look for `;extension=gd.so` and remove the `;` – delboy1978uk Sep 14 '17 at 11:16
  • I can't find gd.so line in php.ini file. There are several thing which ends with .so extension. Couldn't know which to uncomment @delboy1978uk – flixy Sep 14 '17 at 11:20
  • do a `phpinfo(); exit;` at the top of a page, and then CTRL-F to find `GD`, and `.ini`. It's installed if it has it's own section, however it could come from another ini file, so search ini and it will show all the ini files loaded. If it's not in any of them, try the `apt-get` command to install it. – delboy1978uk Sep 14 '17 at 11:22
0

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();
?>
Shanu k k
  • 1,235
  • 2
  • 18
  • 43
  • New Error afer removing semicolon:- A PHP Error was encountered Severity: Core Warning Message: PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20160303/php_gd2.dll' - /opt/lampp/lib/php/extensions/no-debug-non-zts-20160303/php_gd2.dll: cannot open shared object file: No such file or directory Filename: Unknown Line Number: 0 Backtrace: – flixy Sep 14 '17 at 11:15
  • @filxy after remove semicolon you should restart apache – Shanu k k Sep 14 '17 at 11:16
0

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();
Ali Hassan
  • 779
  • 10
  • 14
-1

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

Rohit Sharma
  • 1,271
  • 5
  • 19
  • 37
tasag
  • 1