0

I have a png image which will be downloaded When an user clicks on the download icon, Now the image is downloading on the same webpage in which it is open. I want to make the image download in an new webpage. Here is the code below and i cannot find where to change the code to make it download on a new web page. I think the code that should be modified is...

header("Content-disposition: attachment; filename=\"$iconName".$sizeName.".png\"");

If you want to see the full code, it is as follows. Please help me to solve this problem....

<?php
    ob_start();

    require "../config.php";

    error_reporting(0);

    $icon = $_GET['icon'];
    $iconName = str_replace(".png", "", $_GET['in']);

    $dimensions = $_GET['size'];
    $padding = $_GET['padding'];

    $bgShape = $_GET['bgShape']; if(!$bgShape) $bgShape = 'TransparentCNT.png';
    $bgColorR = $_GET['bgColorR'];
    $bgColorG = $_GET['bgColorG'];
    $bgColorB = $_GET['bgColorB'];

    $iconColorR = $_GET['iconColorR'];
    $iconColorG = $_GET['iconColorG'];
    $iconColorB = $_GET['iconColorB'];

    /////////////////////////////////////////////////////////// 

    $final_image = imagecreatetruecolor($dimensions, $dimensions);
    imagealphablending($final_image, false);
    $transparency = imagecolorallocatealpha($final_image,  0, 0, 0, 127);
    imagefilledrectangle($final_image, 0, 0, $dimensions, $dimensions, $transparency);
    imagesavealpha($final_image, true);
    imagealphablending($final_image, true);

    if($bgShape != '') {
        list($originalWidth, $originalHeight) = getimagesize('../images/' . $bgShape);

        $background = imagecreatefrompng('../images/' . $bgShape);

        imagefilter($background, IMG_FILTER_BRIGHTNESS, -255);
        imagefilter($background, IMG_FILTER_COLORIZE, $bgColorR, $bgColorG, $bgColorB);

        $backgroundImage = imagecreatetruecolor( $dimensions, $dimensions );
        imagealphablending($backgroundImage , false);
        imagesavealpha($backgroundImage , true);

        imagecopyresampled($backgroundImage,
            $background,
            0, 0,
            0, 0,
            $dimensions, $dimensions,
            $originalWidth, $originalHeight
        );

        imagecopy($final_image, $backgroundImage, 0, 0, 0, 0, $dimensions, $dimensions);
    }

    $icon = imagecreatefrompng("../" . $icon);

    imagefilter($icon, IMG_FILTER_BRIGHTNESS, -255);
    imagefilter($icon, IMG_FILTER_COLORIZE, $iconColorR, $iconColorG, $iconColorB);

    $iconImage = imagecreatetruecolor( $dimensions, $dimensions );
    imagealphablending($iconImage, false);
    $transparency = imagecolorallocatealpha($iconImage,  0, 0, 0, 127);
    imagefilledrectangle($iconImage, 0, 0, $dimensions, $dimensions, $transparency);
    imagesavealpha($iconImage, true);
    imagealphablending($iconImage, true);

    imagecopyresampled($iconImage,
        $icon,
        0, 0,
        0, 0,
        $dimensions - ($padding * 2), $dimensions - ($padding * 2),
        $originalWidth, $originalHeight
    );

    imagecopy($final_image, $iconImage, $padding, $padding, 0, 0, $dimensions, $dimensions);

    ///

    if($demoMode) {
        $icon2 = imagecreatefrompng("../images/Mask.png");

        imagesavealpha($icon2, true);
        imagealphablending($icon2, true);

        imagecopy($final_image, $icon2, 0, 0, 0, 0, $dimensions, $dimensions);
    }

    ///

    imagealphablending($final_image,`8true);
    imagesavealpha($final_image, true);

    imagepng($final_image, NULL, 0, PNG_NO_FILTER);

    header("Content-Type: image/png");
    header("Content-Transfer-Encoding: Binary");

    $sizeName = "";
    if($includeSizeInDownloadNames) $sizeName = "-" . $dimensions;

    header("Content-disposition: attachment; filename=\"$iconName".$sizeName.".png\""); 

?>
Sai
  • 11
  • 1
  • 4

1 Answers1

1

Use target = _blank attribute http://www.w3schools.com/tags/att_a_target.asp

MaT
  • 41
  • 3