1

サーバーで GD Imagepng() を使用すると問題が発生しました。私のコードはローカル コンピューターで正常に動作し、ファイルを正しく作成し、正しく保存しますが、サーバーでは動作しません。

私は多くの投稿を見て、成功せずに多くのことを試みました. すべての GD 要素が有効になっています。画像を保存せずにページに直接出力すると機能しますが、保存しようとするとすぐに機能しなくなります。「カスタム」フォルダーのアクセス許可は 777 に設定されています。私の php ファイルは ID ANSI でコード化されています。

これが私のコードです:

function random($car) {
    $string = "";
    $chaine = "abcdefghijklmnpqrstuvwxy1234567890";
    srand((double)microtime()*1000000);
    for($i=0; $i<$car; $i++) {
        $string .= $chaine[rand()%strlen($chaine)];
    }
    return $string;
}


$pathPictures = Array();
$pathSmall = "images/custom/pure/166x250/";
$pathMid = "images/custom/pure/464x700/";
$pathBig = "images/custom/pure/1770x2668/";
array_push($pathPictures, $pathSmall, $pathMid, $pathBig);

$sizes=Array('166x250', '464x700' ,'1770x2668');
$colorRGB = explode(',', str_replace(array('rgb(', ')'), '', $_POST["selectedColor"]));

$selectedPictures = Array();
array_push($selectedPictures, $_POST["selectedStringerImg"]);
array_push($selectedPictures, $_POST["selectedGraphicImg"]);
array_push($selectedPictures, $_POST["selectedFinsFuturesLeftImg"]);
array_push($selectedPictures, $_POST["selectedFinsFuturesCenterImg"]);
array_push($selectedPictures, $_POST["selectedFinsFuturesRightImg"]);
array_push($selectedPictures, $_POST["selectedFinsFCSImg"]);
array_push($selectedPictures, "mask-pure.png");

$pixName = random(25);

for($a=0;$a<=2;$a++){
    $size = explode('x', $sizes[$a]);
    $x=$size[0];
    $y=$size[1];
    $final_img = imagecreatetruecolor($x, $y);
    $color = imagecolorallocatealpha($final_img, $colorRGB[0], $colorRGB[1], $colorRGB[2], 0);
    imagefill($final_img, 0, 0, $color);

    foreach($selectedPictures as $pix){
     $image = imagecreatefrompng($pathPictures[$a].$pix);
     imagecopy($final_img, $image, 0, 0, 0, 0, $x, $y);
        imagealphablending($image, false);
        imagesavealpha($image, true);
    };
    imagepng($final_img, $pathPictures[$a].'custom/'.$pixName.'.png');
};
echo $pathSmall.'custom/'.$pixName.'.png';

あなたの助けに感謝し、良い一日を!

4

0 に答える 0