PDA

View Full Version : How to save file



vmaster
30 Apr 2010, 3:00 PM
Hi. I'm wondering, how to save file ( that means - text from TextArea). Is there any special option, function in GXT or GWT ? How to create "Save as" button ?

Thank you.

vmaster
2 May 2010, 2:53 AM
Any idea ?

sven
2 May 2010, 2:54 AM
You want to save the file on the local file system? That will not work.

Use textArea.getValue() and send this value to the server ans save it there.

vmaster
2 May 2010, 3:19 AM
I want to save the file on the local file system ( user's hard drive, not server disk).
For example, I have TextArea with some text, and if user want to save this text on his hard drive, will click on "Save as" button, select a path on his hard drive and save this text as .txt file.

I have noticed that ToolButton has style: x-tool-save (small floppy icon) - how to write Listener ?

Thanks for help.

sven
2 May 2010, 3:19 AM
You cannot write on the local file system crossbrowser and with pur javascript

vmaster
2 May 2010, 3:31 AM
And how to obtain the window like this: http://www.domorethanmanage.com/articles/2009/01/22/The_Save_As_window_appears.JPG ?

sven
2 May 2010, 3:40 AM
As i said two times now. It is not possible with pur javascript, without browser addons. You need to rethink your application design

Ekambos
8 Jun 2010, 12:41 AM
Come on people,

please stay polite.
We dont need this around here.

Swen is right. U can not write to the hard disc with pure JavaScript. When your page is doing is downloading the file wich is quiet different then saving the file to the local disc.

johnsmith16801
8 Jun 2010, 6:28 AM
Ekambos,
If you look carefully, the content of the file to down (prompted you to save to local HD) is exactly the same content in the textarea. Yes, JavaScript can't write to local HD directly, but with server side help, you can do it WITHOUT any browser add-on and this technology has been well known for over 15 year.

sven
8 Jun 2010, 7:16 AM
You cannot write to the locale hdd with javascript. This is what i am saying and this is correct and it is good that oyu cannot do it.

It only works with a server roundtrip but that was not part of the question here.