but i have a problem with that. I extract the image from php file as under:-
<img src="http://localhost/wordpress/image.php" class="downloadable" id="mainimage"/>
and then i want to download it with javascript as under:-
$('img.downloadable').each(function(){
var $this = $(this);
$this.wrap('<a href="' + $this.attr('src') + '" download />')
});
The problem is that it download php file but i want to download it as PNG.
Extracts of image.php are as under:-
header ("Content-type: image/png");
$userinput = $_GET["user_input"];
$image=imagecreatefrompng('myimages/***image.png***');
$font_file = 'fonts/PR8Charade.ttf';
$col1 = imagecolorallocate($image, 129, 125,11);
$text_size1 = 36;
$xposition1 = 245;
$yposition1 = 380;
$angeldirection1 = 50;
imagettftext($image, $text_size1, $angeldirection1, $xposition1, $yposition1, $col1, $font_file, $userinput);
ImagePng($image);
imagedestroy($image);
I want to download the image.png file from image.php.