Solved

Saving locally through the browser?

Posted on 2002-03-06
12
165 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
return false must be hit after calling certain command 10 43
Powershell script does not exit 4 45
I'm a Human captcha checkbox 13 39
Sending ASP to server side 8 28
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

740 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