2

我正在使用库 WideImage 将上传的图像调整为两个单独的大小,然后将图像保存在两个单独的目录中。问题是较小的图像并不总是保存。这是我的尝试:

 if(move_uploaded_file($_FILES['image']['tmp_name'], "../images/temp/$id.jpg")){
        include '../../WideImage/WideImage.php';
        $successfull = 0;
        if($image = WideImage::load("../images/temp/$id.jpg")){
            if($large=$image->resize(500, 375)){
                $large->saveToFile("../images/large/product_$id.jpg");
                $successfull = 1;
            }
        }

        if($successfull==1){
            $successfull = 0;
            if($image_2 = WideImage::load("../images/temp/$id.jpg")){
                if($small=$image_2->resize(300, 225)){
                    $small->saveToFile("../images/small/product_$id.jpg");
                    $successfull = 1;
                }
            }


        if($successfull!=1){
            $showError='style="background:#c60000;"';
            $myError="An Error Occured Please Try Again";
        }
        else {
            unlink("../images/temp/$id.jpg");
            header("location: products.php");
            exit;
        }
    }

这总是给我一个错误。我的假设是保存图像需要一些时间。所以我的问题是如何确保所有步骤都已成功完成?

4

0 回答 0