Ho ridotto all'osso il codice per semplificare...
Lo script che crea l'immagine dinamicamente:
Codice PHP:
$file_sorgente = './tessera_associato_qrcode.png' ;
$immagine_destinazione = imagecreatefrompng($file_sorgente) ;
header('Content-type: image/png') ;
imagepng($immagine_destinazione) ;
imagedestroy($immagine_destinazione) ;
Lo script che forza il download:
Codice PHP:
$file = '../grafica/tessera_associati/img2.php' ;
$filename = 'img.png' ;
header("Pragma: public") ;
header("Cache-Control: no-store, no-cache, must-revalidate") ;
header("Content-type: application/force-download") ;
header("Content-Transfer-Encoding: binary") ;
header("Content-Description: File Transfer") ;
header("Content-Disposition: attachment; filename= ".$filename ) ;
readfile($file) ;