File output

31 views
Skip to first unread message

bill

unread,
Dec 11, 2009, 9:10:27 AM12/11/09
to prototype-s...@googlegroups.com
I am a relative AJAX neophyte and a complete newbe to prototype.

I have an application that successively loads a series of php pages into the same div without problem using Ajax.updater.
The last php script, instead of generating html, writes a file to the output in OpenOffice Writer format (with the appropriate headers) so instead of displaying the result I want it to do a file download.  (http://www.phpclasses.org/browse/package/5797.html)

Now we get to the place I am lost.

I presume that instead of Ajax.updater I want to do something else  (Ajax Request ?) but I am not sure how to do this.
-- 
Bill Drescher
william {at} TechServSys {dot} com

speed...@gmail.com

unread,
Dec 11, 2009, 9:43:33 AM12/11/09
to Prototype & script.aculo.us
I'm not sure if it's the right way to do, but I just do an http call
(just link to the url), and make sure that my PHP script returns the
appropiate headers for the browser to download the file rather than
open it inline...

I don't think you need ajax for this...

Alex McAuley

unread,
Dec 11, 2009, 9:49:59 AM12/11/09
to prototype-s...@googlegroups.com
Ajax cannot process a file download in the same way it cannot process a file
upload...

You have to output the link and make the user click it


Alex Mcauley
http://www.thevacancymarket.com
--

You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to
prototype-s...@googlegroups.com.
To unsubscribe from this group, send email to
prototype-scripta...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Brian Williams

unread,
Dec 11, 2009, 9:52:23 AM12/11/09
to prototype-s...@googlegroups.com
you would be exactly right.

and to protect from hot linking then check the http referrer or a session variable and if that fails then redirect to a landing page.

you want to investigate the following header info

//cache controlling
header("Cache-Control: public");
//force download
header("Content-Description: File Transfer");
//set filename
header("Content-Disposition: attachment; filename=export.csv");

there are others of course


Alex McAuley

unread,
Dec 11, 2009, 10:08:50 AM12/11/09
to prototype-s...@googlegroups.com
I'm not often wrong but i am right this time !!!
 

speed...@gmail.com

unread,
Dec 11, 2009, 10:35:35 AM12/11/09
to Prototype & script.aculo.us
he replied to my mail :p I guess we're all right this time - what a
wonderful world it is ;)

On Dec 11, 4:08 pm, "Alex McAuley" <webmas...@thecarmarketplace.com>
wrote:
> I'm not often wrong but i am right this time !!!
>
> Alex Mcauleyhttp://www.thevacancymarket.com
>
>   ----- Original Message -----
>   From: Brian Williams
>   To: prototype-s...@googlegroups.com
>   Sent: Friday, December 11, 2009 2:52 PM
>   Subject: Re: [Proto-Scripty] Re: File output
>
>   you would be exactly right.
>
>   and to protect from hot linking then check the http referrer or a session variable and if that fails then redirect to a landing page.
>
>   you want to investigate the following header info
>
>   //cache controlling
>   header("Cache-Control: public");
>   //force download
>   header("Content-Description: File Transfer");
>   //set filename
>   header("Content-Disposition: attachment; filename=export.csv");
>
>   there are others of course
>
>   On Fri, Dec 11, 2009 at 9:43 AM, speedpac...@gmail.com <speedpac...@gmail.com> wrote:
>
>     I'm not sure if it's the right way to do, but I just do an http call
>     (just link to the url), and make sure that my PHP script returns the
>     appropiate headers for the browser to download the file rather than
>     open it inline...
>
>     I don't think you need ajax for this...
>
>     On Dec 11, 3:10 pm, bill <will...@techservsys.com> wrote:
>     > I am a relative AJAX neophyte and a complete newbe to prototype.
>
>     > I have an application that successively loads a series of php pages into
>     > the same div without problem using Ajax.updater.
>     > The last php script, instead of generating html, writes a file to the
>     > output in OpenOffice Writer format (with the appropriate headers) so
>     > instead of displaying the result I want it to do a file download.  
>     > (http://www.phpclasses.org/browse/package/5797.html)
>
>     > Now we get to the place I am lost.
>
>     > I presume that instead of Ajax.updater I want to do something else  
>     > (Ajax Request ?) but I am not sure how to do this.
>
>     > --
>     > Bill Drescher
>     > william {at} TechServSys {dot} com
>
>     --
>
>     You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group.
>     To post to this group, send email to prototype-s...@googlegroups.com.
>     To unsubscribe from this group, send email to prototype-scripta...@googlegroups.com.
>     For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en.

bill

unread,
Dec 11, 2009, 4:38:02 PM12/11/09
to prototype-s...@googlegroups.com
speed...@gmail.com wrote:
he replied to my mail :p  I guess we're all right this time - what a
wonderful world it is ;
  
I haven't replied at all, until now.

On Dec 11, 4:08 pm, "Alex McAuley" <webmas...@thecarmarketplace.com>
wrote:
  
I'm not often wrong but i am right this time !!!
    
I feel much better about not being able to do what I couldn't do.
I guess I will open the last script in a new window and go from there.
Thanks all.

Alex is always right, as far as I know.

Alex McAuley

unread,
Dec 11, 2009, 5:38:04 PM12/11/09
to prototype-s...@googlegroups.com
Not always m8 but thanks for the confidence!!!!!!!!!
----- Original Message -----
From: bill
Sent: Friday, December 11, 2009 9:38 PM
Subject: Re: [Proto-Scripty] Re: File output

--

speed...@gmail.com

unread,
Dec 12, 2009, 5:00:42 AM12/12/09
to Prototype & script.aculo.us
Hi,

No need to open a new window - if it starts downloading you'll be left
with an empty window ;)
Just do an HTTP call to the server and your original page will remain
in the window if you have the correct headers going out from your
PHP...

David

On Dec 11, 10:38 pm, bill <will...@techservsys.com> wrote:

bill

unread,
Dec 12, 2009, 5:59:02 AM12/12/09
to prototype-s...@googlegroups.com
speed...@gmail.com wrote:
Hi,

No need to open a new window - if it starts downloading you'll be left
with an empty window ;)
Just do an HTTP call to the server and your original page will remain
in the window if you have the correct headers going out from your
PHP...
  
Would you be so kind as to expand your suggestion, perhaps with a line of code ?
David
  

bill

unread,
Dec 12, 2009, 3:50:49 PM12/12/09
to prototype-s...@googlegroups.com
speed...@gmail.com wrote:
Hi,

No need to open a new window - if it starts downloading you'll be left
with an empty window ;)
Just do an HTTP call to the server and your original page will remain
in the window if you have the correct headers going out from your
PHP...

  
Interestingly enough, when I do a window.open() and the script just does a download, the window does not actually open, just the download dialog.  No orphan window after that (in FireFox).

David

On Dec 11, 10:38 pm, bill <will...@techservsys.com> wrote:
  
speedpac...@gmail.com wrote:
    
he replied to my mail :p  I guess we're all right this time - what a
wonderful world it is ;
      
I haven't replied at all, until now.> On Dec 11, 4:08 pm, "Alex McAuley" <webmas...@thecarmarketplace.com>
    
wrote:
      
I'm not often wrong but i am right this time !!!
        
I feel much better about not being able to do what I couldn't do.
I guess I will open the last script in a new window and go from there.
Thanks all.

Alex is always right, as far as I know.

--
Bill Drescher
william {at} TechServSys {dot} com
    
--

You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group.
To post to this group, send email to prototype-s...@googlegroups.com.
To unsubscribe from this group, send email to prototype-scripta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.



  

Reply all
Reply to author
Forward
0 new messages