JBTALKS.CC

标题: php “ imagecreatefromjpeg” 问题!! [打印本页]

作者: 狂天使    时间: 2010-3-7 02:54 PM
标题: php “ imagecreatefromjpeg” 问题!!
各位为什么当我跑以下的code时候,会出现这个 error 呢 ? Fatal error: Call to undefined function imagecreatefromjpeg()
请问哪里出了错误?




<?php

    // Checks if the form was submitted
    if($_SERVER['REQUEST_METHOD'] == 'POST') {

        // Checks if a file was uploaded without errors
        if(isset($_FILES['photo'])
        && is_uploaded_file($_FILES['photo']['tmp_name'])

        && $_FILES['photo']['error']==UPLOAD_ERR_OK) {

            // Checks if the file is a JPG image
            if($_FILES['photo']['type']=='image/jpeg') {
                $tmp_img = $_FILES['photo']['tmp_name'];

                // Creates an image resource
                $image = imagecreatefromjpeg($tmp_img);

                // Tells the browser what type of file
                header('Content-Type: image/jpeg');

                // Outputs the file to the browser
                imagejpeg($image, '', 90);

                // Frees the memory used for the file
                imagedestroy($image);
            } else {
                echo "Uploaded file was not a JPG image.";
            }
        } else {
            echo "No photo uploaded!";
        }
    } else {
    // If the form was not submitted, displays the form HTML

?>

<form action="test1.php" method="post" enctype="multipart/form-data">
    <label for="photo">User Photo:</label>
    <input type="file" name="photo" />
    <input type="submit" value="Upload a Photo" />
</form>

<?php } // End else statement ?>
作者: 宅男-兜着走    时间: 2010-3-7 03:15 PM
标题: 回复 #1 狂天使 的帖子
http://php.net/manual/en/book.image.php

确定你的有没有 GD extension。 因为这个 function 是 GD的一部分。
作者: 狂天使    时间: 2010-3-7 03:48 PM
怎样检查我又没有GD extension 呢?在phpinfo()哪里看呢?
作者: 狂天使    时间: 2010-3-7 04:04 PM
谢谢,已经可以了,我在php.ini 关了;extension=php_gd2.dll 那个simicolum就可以了!!还是要说声谢谢哦!!




欢迎光临 JBTALKS.CC (https://www.jbtalks.cc/) Powered by Discuz! X2.5