开发者

PHP's imagecreatefromstring function not working on Amazon Linux Server

I have created a script in which a i have to create a image at runtime using a 64bitencoded string .i m using imagecreatefromstring function of PHP but it works in my Windows XAMPP based PHP , but not on my cloud side applications which i deployed on Amazon cloud running SUSE version of Linux.

Can u give me any suggestion to overcome the problem. Or is there any other function which is capable to create the image from the encoded string passed to it.

Thanks in adv

I am u开发者_高级运维sing following code

<?php
         require ('../dbconfig/dbConfig.php');

    $gameId = $_POST["gameId"];
    $username = $_POST['email'];
    $imagedata =  $_POST['imagedata'];

    $uploaddir = './../blogdata/i/'; 

    $countSql =  mysql_query("select  max(_id) as fileName  from blog_data ");

    while($rowCommentData = mysql_fetch_assoc($countSql))
    {
        $num = $rowCommentData["fileName"];
        $file = ++$num.".png";
        $filedb = $uploaddir .$file;
    }


   /* $imagedata= 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl'
               . 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr'
               . 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r'
               . '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';*/

    $imagedata= base64_decode($imagedata);

    if(($img = @imagecreatefromstring($imagedata)) !== FALSE) 
    {

            if(imagepng($img,$filedb))
            {       
                    imagedestroy($img);

                    $sql="Insert into blog_data (game_id,text,type,username)".
                                   "Values('$gameId','$file','i','$username')";

                    $result=mysql_query($sql);

                    if($result == 1)
                    {
                        echo $file; 
                    }
                    else
                    {
                        echo "error2";
                    }
            } 
            else {
                echo "error1";
            }               
                   }
    else
    { 
         echo "error0";
    }

?>

By running PHP info there i got this information

PHP's imagecreatefromstring function not working on Amazon Linux Server


The PHP needs to have the libgd extension installed and loaded. Check phpinfo() if it's there. You probably can install it via yum. The package should be called php5-gd


From your code, it seems that you dont have the GD extension installed. Please check the phpinfo output and look for the GD extension


You will need root access to the server, which I don't think you get with Amazon's cloud service. You will need to recompile php with --with-gd flag.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜