Solved

Saving locally through the browser?

Posted on 2002-03-06
12
142 Views
Last Modified: 2011-09-20
Greetings,

What I currently have is a XML editor in browser. I wish to do is allow the user to save the XML file to their local machine. Does anyone know how or if this is possible?

TIA

MistaBiggz
0
Comment
Question by:MistaBiggz
12 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6845031
They can save the html page.  They can cut and paste to a text file or they can download a file from the server and save it.  If they are editing a file form the server, then it has to be saved back to the server and then they can download it.  

I think that about covers the options, unless there is activex or a plugin involved.

Cd&
0
 

Author Comment

by:MistaBiggz
ID: 6845156
I'm utilizing servlets and JavaBeans in this application so I can save the file to the server. Is there a way to instantiate the "Save to Disk" dialogue without having the user click on a link to the file on the server?
0
 
LVL 19

Expert Comment

by:webwoman
ID: 6845235
Not really. You want them to save it, there has to be a link of some kind or they need to have the page open.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6845597
Unfortunately, there is no way to do any sort of binding across the pages.  So you will have to come back with the link so they can do a conventional save. Once the browser sends the save to the server is becomes dumb until the server sends back something for it to process.

Cd&
0
 
LVL 3

Expert Comment

by:malcx
ID: 6846721
Use a signed applet or activeX controls to save to a local disk on the users machine.
0
 
LVL 4

Expert Comment

by:vindevogel
ID: 6850806
    <html>
          <head>
               <script language=vbscript>
                    sub download
                         set vDoc = createobject("Scripting.FileSystemObject")
                         set vStream = vDoc.CreateTextFile ("c:\test.xml")
                         set vframe = window.document.all("myframe")
                             
                         vStream.write vFrame.contentwindow.document.body.innertext
                             
                         
         
                    end sub
               </script>
          </head>
         
          <body>
               <a href="#" onclick="Download()">to the xml file</a>
               
               <iframe name=myframe id=myframe src="test.xml"></iframe>
          </body>
     </html>



This page does not do what you want completely, but it might be worth looking at ...

On my machine it saves the content of test.xml to a file c:\test.xml.  It says that it's unsafe (due to the filescripting object).  

So, this might help you on your way, but it's only for IE 5 and you must have the FileSystemObject installed.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 4

Expert Comment

by:vindevogel
ID: 6850882
sub download
     set vDoc = createobject("Scripting.FileSystemObject")
     set vStream = vDoc.CreateTextFile ("c:\test.xml")
     set vframe = window.document.all("myframe")
                             
     vText = vFrame.contentwindow.document.body.innertext
                         
     vText = mid(vText, 3)
     vPos = 1
                         
     do
          vPos = instr(vPos + 3, vText, chr(10))
                             
          if vPos > 0 then
               vText = left(vText, vPos - 2) & vbcrlf & mid(vText, vPos + 3)
          end if
     loop until vPos = 0
                         
     vStream.write vText
end sub


This script is better  :-))
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 200 total points
ID: 6854865
clientside:

- Create an iframe:
<iframe name="fHidden" style="position:absolute;visibility:hidden;" src="about:blank"></iframe>

- add following script and call whenever necessary
<script>
function saveContent(sText, sDestination)
{
    if(document.layers) return false;
    document.frames[sDestination"].document.body.innerHTML = sText;
    document.frames[sDestination"].document.execCommand("SaveAs");
   return true;
}
</script>

- Call it like:
saveContent("<xml version=......><...>", "fHidden");
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6892547
Is this completed, or is more needed?

Cd&

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6975489
This question has been abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6990031
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

<recommendation>
points to CJ_S

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&
0
 
LVL 1

Expert Comment

by:Computer101
ID: 6990713
Comment from expert accepted as answer.

Computer101
E-E Moderator
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now