download file from an ajax request
| From: | pere roca | Date: | Fri, 20 Jun 2008 12:02:35 +0000 |
| Subject: | download file from an ajax request | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-275681@lists.php.net to get a copy of this message | ||
hi everybody!
Hi!
is there some way to allow downloading a PHP generated file from an ajax
request?
the simple code below generates the image but not prompts the "save or open
file..." (it works if I call it directly, not from an HTML and using
ajax...)
thanks,
Pere
$layer=$_GET['params']; //coming from ajax request
$image0="http://edit3.csic.es/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SERVICE=WMS&LAYERS=".$layer."&STYLES=&format=image/png&bbox=-9.65,35.6,4.85,43.85&WIDTH=760&HEIGHT=380&SLD=http://edit.csic.es/fitxers/sld/pou.sld";
$image=imagecreatefrompng($image0);
imagepng($image,'definitius_hola.png');
//Opens file or URL
$h = fopen("definitius.png", "r");
header("Content-Type: image/png");
header("Content-Disposition: attachment; filename=\"definitius.png");
fpassthru($h);
fclose($h);
--
View this message in context: http://www.nabble.com/download-file-from-an-ajax-request-tp18028188p18028188.html
Sent from the PHP - General mailing list archive at Nabble.com.