View Full Version : Store file from remote server to client


=?Utf-8?B?U3JpcHJpeWE=?=
Hai,

I have an asp page where i display some details in the html table. I am
exporting this details to an excel which by default is getting stored in the
server in c:/winnt/system32 folder. But i want to store the excel file in the
client machine itself. I tried giving so many paths to store the file in the
client machine by getting the IP address of the client and then giving a path
like c:/ or so. But i get an error telling permission denied. I would also
like to know the technique with which all the files we access are stored in
Temporary Internet files folder. when i manually gave the path of the
temporary internet files folder for storing the excel, still i get the
same error as permission denied.

Set fs = Server.CreateObject("Scripting.FileSystemObject")
'Response.Write "\\" & Request.servervariables("REMOTE_ADDR") &
"\c\documents and settings\administrator\Local Settings\Temporary Internet
Files\" & trim(Request("SavefileName")) & ""
'Response.Write "\\" & Request.servervariables("REMOTE_ADDR") &
"\c\documents and settings\All Users\Documents\" &
trim(Request("SavefileName")) & ""
'Response.End
'Set MyFile = fs.CreateTextFile("\\" &
Request.servervariables("REMOTE_ADDR") & "\c\documents and
settings\administrator\Local Settings\Temporary Internet Files\" &
trim(Request("SavefileName")) & "", True)
Set MyFile = fs.CreateTextFile("\\" &
Request.servervariables("REMOTE_ADDR") & "\c\documents and settings\All
Users\Documents\" & trim(Request("SavefileName")) & "", True)

strLine=""

For each x in rs.Fields
'Separate field names with tab so that these appear in
'different columns in Excel
strLine= strLine & x.name & chr(9)
Next

'Write this string into the file
MyFile.writeline strLine

Do while Not rs.EOF
strLine=""
for each x in rs.Fields
strLine= strLine & x.value & chr(9)
next
MyFile.writeline strLine
rs.MoveNext
Loop
MyFile.Close
Set MyFile=Nothing
Set fs=Nothing

This is the code i use for excel export

Basic idea is to run an asp page in the remote server and store the excel
file after exporting the data to the client.
Could anyone help me out on this.

Thanks & Regards,
K. Sripriya

Steve Cochran
This is off topic for an Outlook Express newsgroup.

There are explicit security checks to prevent files from being saved on the
local machine, so you can't really do this without user intervention on the
client side to allow such.

steve

"Sripriya" wrote in message
news:3082B1F7-2AC5-48EF-AE28-3B8FF6F1B367@microsoft.com...
> Hai,
>
> I have an asp page where i display some details in the html table. I am
> exporting this details to an excel which by default is getting stored in
> the
> server in c:/winnt/system32 folder. But i want to store the excel file in
> the
> client machine itself. I tried giving so many paths to store the file in
> the
> client machine by getting the IP address of the client and then giving a
> path
> like c:/ or so. But i get an error telling permission denied. I would also
> like to know the technique with which all the files we access are stored
> in
> Temporary Internet files folder. when i manually gave the path of the
> temporary internet files folder for storing the excel, still i get the
> same error as permission denied.
>
> Set fs = Server.CreateObject("Scripting.FileSystemObject")
> 'Response.Write "\\" & Request.servervariables("REMOTE_ADDR") &
> "\c\documents and settings\administrator\Local Settings\Temporary Internet
> Files\" & trim(Request("SavefileName")) & ""
> 'Response.Write "\\" & Request.servervariables("REMOTE_ADDR") &
> "\c\documents and settings\All Users\Documents\" &
> trim(Request("SavefileName")) & ""
> 'Response.End
> 'Set MyFile = fs.CreateTextFile("\\" &
> Request.servervariables("REMOTE_ADDR") & "\c\documents and
> settings\administrator\Local Settings\Temporary Internet Files\" &
> trim(Request("SavefileName")) & "", True)
> Set MyFile = fs.CreateTextFile("\\" &
> Request.servervariables("REMOTE_ADDR") & "\c\documents and settings\All
> Users\Documents\" & trim(Request("SavefileName")) & "", True)
>
> strLine=""
>
> For each x in rs.Fields
> 'Separate field names with tab so that these appear in
> 'different columns in Excel
> strLine= strLine & x.name & chr(9)
> Next
>
> 'Write this string into the file
> MyFile.writeline strLine
>
> Do while Not rs.EOF
> strLine=""
> for each x in rs.Fields
> strLine= strLine & x.value & chr(9)
> next
> MyFile.writeline strLine
> rs.MoveNext
> Loop
> MyFile.Close
> Set MyFile=Nothing
> Set fs=Nothing
>
> This is the code i use for excel export
>
> Basic idea is to run an asp page in the remote server and store the excel
> file after exporting the data to the client.
> Could anyone help me out on this.
>
> Thanks & Regards,
> K. Sripriya