Solved

Saving locally through the browser?

Posted on 2002-03-06
12
153 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

770 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