Saving server side file to local machine with JS

Saving server side file to local machine with JS

am 27.07.2009 05:39:35 von Skip Evans

Sorry, I should have been clearer.

When PHP finishes creating the file I need one of the JS alert
type windows to appear that says..

"Your file has completed, would you like to save it to your
machine?"

Like you get when you download a file.

If I knew the JS code to do this I perhaps could embed it in
the PHP at the end of the function that creates the file???

Is that clearer?

Thanks,
Skip


Paul M Foster wrote:
> On Sun, Jul 26, 2009 at 09:55:14PM -0500, Skip Evans wrote:
>
>> Okay, I know I've done this before, but now I'm blanking out.
>>
>> I have code that creates a CSV file, and when it's done I want
>> a JS alert to pop up and let them save the file.
>>
>> Isn't this some kind of alert() type call on the JS side???
>>
>> I know I've done this before and I've been on Google an
hour now!
>
> Not sure I understand your question, but there is a
function called
> alert() in javascript. It opens a window with your error
message in it.
>
> I don't know of a way to trigger this from PHP, since PHP
is server-side
> and Javascript is client-side. You might be able to have
javascript scan
> for the existence/closing of the file in question and then
alert the
> user. Or you could have PHP, when the file is complete,
launch a new
> page which contains the javascript code to alert the user.
>
> Paul
>

--
====================================
Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com
------------------------------------
Those of you who believe in
telekinesis, raise my hand.
-- Kurt Vonnegut

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

Re: Saving server side file to local machine with JS

am 27.07.2009 10:02:41 von Addmissins Development

Skip Evans wrote:
> Sorry, I should have been clearer.
>
> When PHP finishes creating the file I need one of the JS alert type
> windows to appear that says..
>
> "Your file has completed, would you like to save it to your machine?"
>
> Like you get when you download a file.
>
> If I knew the JS code to do this I perhaps could embed it in the PHP at
> the end of the function that creates the file???
>
> Is that clearer?
>
> Thanks,
> Skip

Not sure if you can save it directly.... From javascript!

What you could do is.

1. Make an asynchrome call to a php script on the server with javascript.

2. Once PHP is finished you can make it return a URL to the asynchrome
javascript call. This URl will point to the generated download file.

3. Then with javascript create a nice div with two buttons. One to
initiate the download and the other to cancel...


>
>
> Paul M Foster wrote:
>> On Sun, Jul 26, 2009 at 09:55:14PM -0500, Skip Evans wrote:
>>
>>> Okay, I know I've done this before, but now I'm blanking out.
>>>
>>> I have code that creates a CSV file, and when it's done I want
>>> a JS alert to pop up and let them save the file.
>>>
>>> Isn't this some kind of alert() type call on the JS side???
>>>
>>> I know I've done this before and I've been on Google an hour now!
>>
>> Not sure I understand your question, but there is a function called
>> alert() in javascript. It opens a window with your error message in it.
>>
>> I don't know of a way to trigger this from PHP, since PHP is server-side
>> and Javascript is client-side. You might be able to have javascript scan
>> for the existence/closing of the file in question and then alert the
>> user. Or you could have PHP, when the file is complete, launch a new
>> page which contains the javascript code to alert the user.
>>
>> Paul
>>
>


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