Code Comments
Programming Forum and web based access to our favorite programming groups.Can anyone save me from myself?
I thought it would be reasonable to allow a client-side request to copy a fi
le from a server to the client's own location
ala:
<script language=javascript>
var fso=new ActiveXObject("Scripting.FileSystemObject");
var theFile
theFile=fso.CopyFile("//192.168.1.103/MAIS/Reports/ExportHCFA.txt","c:\temp\
HCFA.txt")
</script>
It's never worked no matter how I form the locations I either get path not f
ound or invliad, file not found or permission denied.
I've been informed this has nothing to do IIS or HTTP but is a UNC type requ
est.
So i read up on UNC and tried:
(this is an well-trusted intranet)
making the reports folder shared with full joy for everyone
and coded:
theFile=fso.CopyFile("\\Bugsbunny\Reports\ExportHCFA.txt","c:\temp\HCFA.txt"
)
yes bugsbunny is the name of the server.
still fails with path not found
I'll repeat: can anyone save me from myself?
or alternatively -- does anyone know where I can find a similar popup type d
ialogue that would allow a server to client transfer not unlike
those which ask "What do you want to do with this file?" dialogues with the
open or save etc. buttons?
thanks, Bryan
Post Follow-up to this message<kuntakinte@roots.com> wrote in message
news:mkkkl0lheotlp8vlcutjs4a03eb6uqn39p@
4ax.com...
> Can anyone save me from myself?
>
> I thought it would be reasonable to allow a client-side request to copy a
file from a server to the client's own location
> ala:
> <script language=javascript>
> var fso=new ActiveXObject("Scripting.FileSystemObject");
> var theFile
>
theFile=fso.CopyFile("//192.168.1.103/MAIS/Reports/ExportHCFA.txt","c:\temp\
HCFA.txt")
> </script>
>
> It's never worked no matter how I form the locations I either get path not
found or invliad, file not found or permission denied.
> I've been informed this has nothing to do IIS or HTTP but is a UNC type
request.
>
> So i read up on UNC and tried:
> (this is an well-trusted intranet)
> making the reports folder shared with full joy for everyone
> and coded:
>
theFile=fso.CopyFile("\\Bugsbunny\Reports\ExportHCFA.txt","c:\temp\HCFA.txt"
)
> yes bugsbunny is the name of the server.
> still fails with path not found
>
> I'll repeat: can anyone save me from myself?
>
> or alternatively -- does anyone know where I can find a similar popup type
dialogue that would allow a server to client transfer not unlike
> those which ask "What do you want to do with this file?" dialogues with
the open or save etc. buttons?
>
> thanks, Bryan
>
You need to escape \ to \\:
theFile=fso.CopyFile("\\\\Bugsbunny\\Reports\\ExportHCFA.txt","c:\\temp\\HCF
A.txt")
Had you alerted the paths before copying you would have seen the problem.
Aa an alternative to setting up a share you retrieve a file from an HTTP ref
using Msxml2.XmlHttp class, here's an example using version 4, you can
change it to version 3 if that's all the client has. It will only run if the
client has the page in question in the "Local intranet" or "Trusted sites"
security zone.
function saveRemoteFile(From, To)
{
var oXmlHttp = new ActiveXObject("Msxml2.XmlHttp.4.0");
oXmlHttp.open("GET", From, false);
oXmlHttp.send();
if (oXmlHttp.status == 200)
{
var oStream = new ActiveXObject("Adodb.Stream");
oStream.type = 1; //Binary
oStream.open();
oStream.write(oXmlHttp.responseBody);
oStream.saveToFile(To, 1 && 2); //Create if needed and overwrite if
necessary
oStream.close();
}
else
{
throw new Error(oXmlHttp.statusText); //Needs improving
}
}
then:
saveRemoteFile("http://www.google.com", "C:\\myFolder\\myFile.htm");
--
Joe (MVP - xml)
Post Follow-up to this messageJoe, Mucho, mucho, Thank You for setting me straight on the unc conventions
. I'd had escaped the earlier "http" attempts but then forgot about them in
the frustration of chasing down the supposed
the new thrust re UNC.
and also thank you for the http/XML soluntion -- haven't tried it yet but wi
ll once the current hubub goes away.
That will be my first foray into XML. Certainly looks tame enough. Aaah famo
us last words.
On Wed, 29 Sep 2004 09:27:30 +0100, "Joe Fawcett" <joefawcett@hotmail.com> w
rote:
><kuntakinte@roots.com> wrote in message
> news:mkkkl0lheotlp8vlcutjs4a03eb6uqn39p@
4ax.com...
>file from a server to the client's own location
>theFile=fso.CopyFile("//192.168.1.103/MAIS/Reports/ExportHCFA.txt","c:\temp
\
>HCFA.txt")
>found or invliad, file not found or permission denied.
>request.
>theFile=fso.CopyFile("\\Bugsbunny\Reports\ExportHCFA.txt","c:\temp\HCFA.txt
"
> )
>dialogue that would allow a server to client transfer not unlike
>the open or save etc. buttons?
>
>You need to escape \ to \\:
>theFile=fso.CopyFile("\\\\Bugsbunny\\Reports\\ExportHCFA.txt","c:\\temp\\HC
F
>A.txt")
>
>Had you alerted the paths before copying you would have seen the problem.
>Aa an alternative to setting up a share you retrieve a file from an HTTP re
f
>using Msxml2.XmlHttp class, here's an example using version 4, you can
>change it to version 3 if that's all the client has. It will only run if th
e
>client has the page in question in the "Local intranet" or "Trusted sites"
>security zone.
>
>function saveRemoteFile(From, To)
>{
> var oXmlHttp = new ActiveXObject("Msxml2.XmlHttp.4.0");
> oXmlHttp.open("GET", From, false);
> oXmlHttp.send();
> if (oXmlHttp.status == 200)
> {
> var oStream = new ActiveXObject("Adodb.Stream");
> oStream.type = 1; //Binary
> oStream.open();
> oStream.write(oXmlHttp.responseBody);
> oStream.saveToFile(To, 1 && 2); //Create if needed and overwrite if
>necessary
> oStream.close();
> }
> else
> {
> throw new Error(oXmlHttp.statusText); //Needs improving
> }
>}
>
>then:
>saveRemoteFile("http://www.google.com", "C:\\myFolder\\myFile.htm");
Post Follow-up to this message<kuntakinte@roots.com> wrote in message news:kdjll05ubomh30nish4mehfk7tg6b6aqn3@ 4ax.com... > Joe, Mucho, mucho, Thank You for setting me straight on the unc conventions. I'd had escaped the earlier "http" attempts but then forgot about them in the frustration of chasing down the supposed > the new thrust re UNC. > and also thank you for the http/XML soluntion -- haven't tried it yet but will once the current hubub goes away. > That will be my first foray into XML. Certainly looks tame enough. Aaah famous last words. > On Wed, 29 Sep 2004 09:27:30 +0100, "Joe Fawcett" <joefawcett@hotmail.com> wrote: > Okay, one thing is that although the XmlHttp class is part of the xml services library it does deal with any remote content, it's not limited to xml documents. Good luck. -- Joe
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.