Re: download file from an ajax request

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 20, 2008 at 8:02 AM, pere roca <peroc79@xxxxxxxxx> wrote:
>
> 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.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

The only thing I can think of is using JS to create some sort of
IFRAME, meta redirect, window.location, or a popup window, something
that will force the page to hit your download script directly.  I've
never attempted it myself so I'm not sure what sort of issues IE would
have with any of the above.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux