PHP图像压缩和调整大小

时间:2014-08-24 23:09:35

标签: javascript php mysql image-processing

我终于得到了下面的代码,将图像上传到我的服务器,并通过帖子表格将图片的名称记录到数据库中。但是我无法将图像缩小。

似乎我的廉价1and1主机没有为GD库分配足够的内存来工作。我知道那里有插件,但我无法解决它(它使用JavaScript),所以任何有关如何压缩图像的帮助都会很棒。

<?php
    echo 'start';
    require_once('uploadpath.php');
    echo 'loadedunloadpath';
    $customerid= $_POST['customerid'];
    $image= $_FILES['image']['name'];
    $image_type = $_FILES['image']['type'];
    $image_size = $_FILES['image']['size'];


    if ($_FILES['image']['error'] == 0) {
        echo 'afterimageerror'; 

        echo("Image created and saved successfully.");
        // Move the file to the target upload folder
        $target = GW_UPLOADPATH . $image;
        echo 'targetuploadpath';
        if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {

            // Connect to the database
            require ('dbconnect.php');
            echo 'dbconnected';
            // Write the data to the database
            $query = "INSERT INTO checkpics (customerid, image) VALUES ('$customerid', '$image')";
            echo 'firstquerycompleted';
            mysqli_query($con, $query);
        }
    }

?>

0 个答案:

没有答案