Re: [PHP] download file from an ajax request

2008-06-20 Thread Daniel Brown
On Fri, Jun 20, 2008 at 2:21 PM, tedd <[EMAIL PROTECTED]> wrote:
>
> Oh, so now you tell us.  :-)

Hey, back off!  You knew I was a horrible person long before this
thread!  ;-P

-- 

Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] download file from an ajax request

2008-06-20 Thread tedd

At 1:00 PM -0400 6/20/08, Daniel Brown wrote:

On Fri, Jun 20, 2008 at 12:59 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:


Once you get your download script fixed, try adding these lines to
 your page:

 
 Click to Download

And just replace img.php with the name of your script.


Sorry, that should be:


Click to Download


Oh, so now you tell us.  :-)

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] download file from an ajax request

2008-06-20 Thread Daniel Brown
On Fri, Jun 20, 2008 at 12:59 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:
>
>Once you get your download script fixed, try adding these lines to
> your page:
>
> 
> Click to Download
>
>And just replace img.php with the name of your script.

Sorry, that should be:


Click to Download

-- 

Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] download file from an ajax request

2008-06-20 Thread Daniel Brown
On Fri, Jun 20, 2008 at 8:02 AM, pere roca <[EMAIL PROTECTED]> wrote:
>
[snip!]
> imagepng($image,'definitius_hola.png');

Here you call it 'definitius_hola.png'

> $h = fopen("definitius.png", "r");
>header("Content-Type: image/png");
>header("Content-Disposition: attachment; filename=\"definitius.png");

Whereas here, you call it 'definitius.png', and also forget the
closing escape quote in the filename="" section.

Once you get your download script fixed, try adding these lines to
your page:


Click to Download

And just replace img.php with the name of your script.


-- 

Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] download file from an ajax request

2008-06-20 Thread Nitsan Bin-Nun
I believe that you don't even have to program it, try to use:


And include download headers on the php file - as far as i remember it
should popup a "save as" dialog.

Regards,
Nitsan

On 20/06/2008, pere roca ristol <[EMAIL PROTECTED]> wrote:
>
>   yes Iv, surely this is a more js/Ajax issue... this is the one who has to
> do something with php answer.
>   sorry,
>
>   Pere
>
> 2008/6/20 Iv Ray <[EMAIL PROTECTED]>:
>
> > Eric Butera wrote:
> >
> >> 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.
> >>
> >
> > Well, if we, the illiterate, are going to brainstorm ;) - clicking a
> > link/button/image executes JavaScript function, which (via AJAX request)
> > hits the php download script. The response will be received by the AJAX
> > object.
> >
> > Nothing php here.
> >
> > As far as I see the problem, it is - how to pass this response to the
> > browser in an elegant way, so that the browser will open a "Save as..."
> > dialogue and will direct the stream there.
> >
> > One could ask this on a JavaScript/AJAX list.
> >
> > Iv
> >
>


Re: [PHP] download file from an ajax request

2008-06-20 Thread Eric Butera
On Fri, Jun 20, 2008 at 8:47 AM, Iv Ray <[EMAIL PROTECTED]> wrote:
> Eric Butera wrote:
>>
>> 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.
>
> Well, if we, the illiterate, are going to brainstorm ;) - clicking a
> link/button/image executes JavaScript function, which (via AJAX request)
> hits the php download script. The response will be received by the AJAX
> object.
>
> Nothing php here.
>
> As far as I see the problem, it is - how to pass this response to the
> browser in an elegant way, so that the browser will open a "Save as..."
> dialogue and will direct the stream there.
>
> One could ask this on a JavaScript/AJAX list.
>
> Iv
>

My point was that you can't (as far as I know).  You have to make the
browser hit the resource directly.  Anything else you just have the
raw response to push into the DOM yourself.  So I tried to point out a
few ways of doing such a thing.  :)

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



Re: [PHP] download file from an ajax request

2008-06-20 Thread pere roca ristol
   yes Iv, surely this is a more js/Ajax issue... this is the one who has to
do something with php answer.
   sorry,

   Pere

2008/6/20 Iv Ray <[EMAIL PROTECTED]>:

> Eric Butera wrote:
>
>> 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.
>>
>
> Well, if we, the illiterate, are going to brainstorm ;) - clicking a
> link/button/image executes JavaScript function, which (via AJAX request)
> hits the php download script. The response will be received by the AJAX
> object.
>
> Nothing php here.
>
> As far as I see the problem, it is - how to pass this response to the
> browser in an elegant way, so that the browser will open a "Save as..."
> dialogue and will direct the stream there.
>
> One could ask this on a JavaScript/AJAX list.
>
> Iv
>


Re: [PHP] download file from an ajax request

2008-06-20 Thread Iv Ray

Eric Butera wrote:

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.


Well, if we, the illiterate, are going to brainstorm ;) - clicking a 
link/button/image executes JavaScript function, which (via AJAX request) 
hits the php download script. The response will be received by the AJAX 
object.


Nothing php here.

As far as I see the problem, it is - how to pass this response to the 
browser in an elegant way, so that the browser will open a "Save as..." 
dialogue and will direct the stream there.


One could ask this on a JavaScript/AJAX list.

Iv

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



Re: [PHP] download file from an ajax request

2008-06-20 Thread Eric Butera
On Fri, Jun 20, 2008 at 8:02 AM, pere roca <[EMAIL PROTECTED]> 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



Re: [PHP] download file from an ajax request

2008-06-20 Thread Iv Ray

pere roca wrote:

hi everybody!

Hi!

is there some way to allow downloading a PHP generated file from an ajax
request?


No idea, but would love to hear if/how you solved it.
Iv

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



Re: [PHP] download file question...

2004-08-19 Thread John Holmes
> From: "bruce" <[EMAIL PROTECTED]>

> i can allow files to be uploaded to my app. are there corresponding
> scripts/code to allow files to be downloaded to the user via the browser??

How about a link to the file? If you want to get more complicated, search the archives 
for "readfile" and "download"...

---John Holmes...

UCCASS - PHP Survey System
http://www.bigredspark.com/survey.html

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



RE: [PHP] download file question...

2004-08-19 Thread Jay Blanchard
[snip]
nothing jumps out at me searching google/php.net for this...
[/snip]

Have you searched the mailing list archives? 

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



RE: [PHP] Download File

2002-11-19 Thread Van Andel, Robert
If the word document you are trying to download is already on the server,
you could probably just make a link to the file

http://host.com/document.doc";>

When the user clicks on it, they either view the document if they have the
MS Word plugin, or they are asked to download it.  I'm not sure that using
php is warranted.

Robbert van Andel 


-Original Message-
From: Michelle [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 19, 2002 7:57 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Download File


I would like to download a word-document from another site and save it to my
harddrive.
How would I go about doing this?

I tried:
http://host.com/document.doc;

$fd = fopen ($filename, "rb");
$string = fread ($fd, filesize ($filename)); 

ERROR:
Warning: stat failed for http://host.com/document.doc (errno=2 - No such
file or directory) in d:\inetpub\wwwroot\dl-doc.php on line 8

I believe this has something to do with the access rights to the folders or
something...




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


 "The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from all
computers." 





Re: [PHP] Download File

2002-11-19 Thread Ernest E Vogelsinger
At 16:56 19.11.2002, Michelle spoke out and said:
[snip]
>I would like to download a word-document from another site and save it to my
>harddrive.
>How would I go about doing this?
>
>I tried:
>$filename = "http://host.com/document.doc;
>
>$fd = fopen ($filename, "rb");
>$string = fread ($fd, filesize ($filename)); fclose ($fd);
[snip] 

 From the docs (http://www.php.net/manual/en/function.filesize.php):

This function will not work on remote files; the file to be examined must
be accessible via the server's filesystem.

You can bypass this by reading until EOF:

http://host.com/document.doc';
$fd = fopen($filename, 'rb');
$string = null;
while ($chunk = fread($fd, 64*128))// read blocks at 64 k
   $string .= $chunk;
fclose($fd);
?>

Untested but it should work as expected.



-- 
   >O Ernest E. Vogelsinger 
   (\) ICQ #13394035 
^ http://www.vogelsinger.at/



Re: [PHP] Download File

2002-11-19 Thread Adam Voigt
PHP is true and blue in relation to error messages (in this case
anyway):

Warning: stat failed for http://host.com/document.doc (errno=2 - No such
> file or directory) in d:\inetpub\wwwroot\dl-doc.php on line 8

The file either doesn't exist on "host.com" under the root directory
as "document.doc" or the webserver (on the host.com side) doesn't have
sufficient permission to serve "document.doc". Can you go to it in a
web browser?

On Tue, 2002-11-19 at 10:56, Michelle wrote:
> I would like to download a word-document from another site and save it to my
> harddrive.
> How would I go about doing this?
> 
> I tried:
>  $filename = "http://host.com/document.doc;
> 
> $fd = fopen ($filename, "rb");
> $string = fread ($fd, filesize ($filename));  fclose ($fd);
> 
> $fname = "my_saved_doc.doc";
> $fp = fopen ($fname, "wb");
> 
> ?>
> 
> ERROR:
> Warning: stat failed for http://host.com/document.doc (errno=2 - No such
> file or directory) in d:\inetpub\wwwroot\dl-doc.php on line 8
> 
> I believe this has something to do with the access rights to the folders or
> something...
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
-- 
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc



signature.asc
Description: This is a digitally signed message part


Re: [PHP] Download File Problem - text not appearing on downloaded file

2001-11-20 Thread Gede Gilijk

Joe,
I have been there:-)
I use this scripts



The first time I run this script, I works fine. The file downloads properly
to the client machine with the right size and content. Most of the file is
text file.
After some times, I met the same problem as yours. The file size is 0.
I don't know, perhaps I change the browser setting or my Admin change the
Apache settings, PHP or some thing else.
I ask everywhere, many mailing list. and I gave up.
I just change it to
Header("Location: $url.$filename");
It works but there is a funny things.
The file can be downloaded properly if the file (with such an extension) has
been opened with notepad. If not, the file will opened in the browser.

:-)...it's an experience.

Gilijk


- Original Message -
From: "Joe Van Meer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 19, 2001 10:43 PM
Subject: [PHP] Download File Problem - text not appearing on downloaded file


> Hi there. I managed to get the prompt for a file download when a user
clicks
> on a text link. The file downloads properly to the client machine, howevr,
> when I open up the file there is no content. What do I have to add to the
> following code to get the content sent back to the user?
>
> Thx Joe :)
>
> 
> header("Content-type: application/octet-stream");
> header("Content-Disposition: attachment; filename=file.txt");
>
> ?>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]