Copying a file from a server to a server

Results 1 to 3 of 3

Thread: Copying a file from a server to a server

  1. #1
    Kim Grittner Guest

    Default Copying a file from a server to a server

    Hi,<BR><BR>I would like to know how I would do the following in ASP.<BR>I have two seperate web sites...Let&#039s say that my first site is<BR>called www.mysite1.com and I have a file called "default.asp" in<BR>the root directory, so the url would be: www.mysite1.com/default.asp<BR><BR>Now, let&#039s say I have a "RUN AT SERVER" script on another website, we&#039ll call it www.mysite2.com and it would like to call the www.mysite1.com/default.asp and read the file.<BR><BR>Is there a way to do this in ASP, without me having to write an<BR>activex dll or something like that? Thanks in advance.

  2. #2
    FileGuy Guest

    Default RE: Copying a file from a server to a server

    you should be able to use the filesystemobject to write everything in asp. go to msdn.microsoft.com/scripting and look under vbscript and then the filesystemobject reference for how to use it

  3. #3
    Kim Grittner Guest

    Default RE: Copying a file from a server to a server

    Thanks for the response. However, the problem I am still <BR>having is that I cannot seem to copy the file from a URL.<BR>Please see the ASP code below that works. It will create a <BR>file on the server then, read it and display the "Hello world"<BR>contents to the screen. However, if you try to read the file<BR>www.w3.org/XML/Activity.html<BR>it will error out. I have put in a line of code you can comment <BR>out and see this happen. How do I copy the www.w3.org/xml/activity.html file to an accessible drive that the filestreaming stuff can read it? Thanks.<BR><BR>====test.asp code follows...It works as is, you must un comment the following line to see the error:<BR>&#039Filename = server.MapPath("www.w3.org/XML/Activity.html")<BR>=====<BR>&#060;%@ Language=VBScript %&#062;<BR>&#060;HTML&#062;<BR>&#060;HEAD&#062;<BR >&#060;META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"&#062;<BR>&#060;/HEAD&#062;<BR>&#060;BODY&#062;<BR>&#060;%<BR>DIM objFileSys<BR>DIM objTextStream<BR>DIM FileName<BR>CONST ForReading = 1<BR>CONST ForWriting = 2<BR>CONST ForAppending = 8<BR><BR>SET objFileSys = Server.CreateObject("Scripting.FileSystemObject")< BR><BR>&#039 The following file will work to create and later read<BR>Filename = server.MapPath("temp3.txt")<BR>Set objTextStream = objFileSys.OpenTextFile(Filename, ForWriting, True)<BR>objTextStream.Write "Hello world!"<BR>objTextStream.Close<BR>Set objTextStream = nothing<BR><BR>&#039If you un-comment the following line, it will cause a "Path not found error." :<BR>&#039Filename = server.MapPath("www.w3.org/XML/Activity.html")<BR><BR>&#039 See if we can open a file for Reading,<BR>Response.Write "About to open: " & Filename<BR>SET objTextStream = objFileSys.OpenTextFile(Filename, ForReading)<BR>sFile = objTextStream.ReadAll<BR>Response.Write " File Contents: " & sFile<BR><BR>&#039 Clean up the variables now<BR>objTextStream.Close<BR>SET objTextStream = nothing<BR>SET objFileSys = nothing<BR>%&#062;<BR>&#060;/BODY&#062;<BR>&#060;/HTML&#062;<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •