Fatal error: Call to undefined function: imagecrea

2019-02-04 00:32发布

问题:

I'm trying to put some graphics on a web page and at my prototype at the computer it's all working fine at the localhost. But now I uploaded the files to a server and I'm having a problem to plot some graphics. In my computer they are plotted, but on the server they are not.

I'm getting this error Fatal error: Call to undefined function ImageCreate() in /home/t1g01/phplot.php on line 248

Line 248

$this->img = ImageCreate($this->image_width, $this->image_height);

I'm using phplot, and I uploaded the files form phplot too. Can anyone help me ?

Sorry for any mistake in English and thank you in advance.

回答1:

This means your installation of php doesn't have the gd library installed/enabled.

http://www.php.net/manual/en/image.installation.php



回答2:

If you are using a Linux machine then execute this command from console:

sudo apt-get install php5-gd

to install the php_gd2.dll extension. It will then work after an Apache restart.



回答3:

Your server most like does not have GD (the built in PHP image processing library) enabled. You can check this by looking for "GD" in the output of :

<?php
phpinfo();
?>

If not, check the PHP docs on how to enable it: http://www.php.net/manual/en/book.image.php



回答4:

For Fedora, CentOS

dnf install php-gd
systemctl restart httpd.service

On Ubuntu

apt-cache search php*-gd
apt-get install php<version>-gd
systemctl restart apache2.service

Windows users see: http://php.net/manual/en/image.installation.php



回答5:

It seems that your GD library is not being used. Double check your php.ini file.



回答6:

  1. Copy the file php_gd2.dll from your PHP's ext/ directory to where you have your php extensions. (No need to copy if php_gd2.dll is in the extension dir already. Look in php.ini for 'extension_dir' directive to find what is your current extension directory)

  2. Modify your php.ini and change the following line:

;extension=php_gd2.dll

to:

extension=php_gd2.dll


回答7:

For Ubuntu 16.04:

sudo apt-get install php7.0-gd

Stop and then restart Apache Server.



标签: php graphics