Solved

Write ftp a file from a classic ASP program

Posted on 2006-11-15
4
1,130 Views
Last Modified: 2011-09-20
How do I ftp a file from a classic asp program stored on a application server?  In other words ftp the file?  I want to transmit the file to my C:\ local drive on my workstation.   I do not want to write or create the file on the server just assemble the file and then transmit.   I have never used a FTP process in classic ASP

dim xmldata
  dim Base64Data
  ' Save the bit file
  Dim objFSO, objFSOText, objFolder, objFile
  Dim strDirectory, strFile
  Const ForAppending = 8
  set objFile = nothing
  set objFolder = nothing

  strFile = "Base64Data.txt"
  'strDirectory=server.mapPath(strFile)
  strDirectory="C:\Inetpub\wwwroot\Base64Data.txt"  ???? How can I transfer this file to workstation?
 
' Create the File System Object
  Set objFSO = CreateObject("Scripting.FileSystemObject")

  Set objFile = objFSO.CreateTextFile(strDirectory)
   
  Set objTextFile = objFSO.OpenTextFile(strDirectory, ForAppending, true)

  Base64Data = oXML.xml
  Base64Data = Base64EncodeBinary(oXML.xml


  objTextFile.WriteLine(Base64Data)
  objTextFile.Close
0
Comment
Question by:Hojoformo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 25

Expert Comment

by:kevp75
ID: 17953376
i'm a bit confused by what you are trying to do...

are you trying to download a file to your computer from a web page?
0
 
LVL 58

Expert Comment

by:amit_g
ID: 17953871
strDirectory="C:\Inetpub\wwwroot\Base64Data.txt"

Call Response.Clear()
Response.ContentType = "application/x-unknown"
Call Response.AddHeader("Content-Disposition", "attachment; filename=Base64Data.txt")
Call Response.Write(ReadFile(strDirectory))
Call Response.End()

Function ReadFile(sFilePathAndName)
   dim sFileContents
   Set oFS = Server.CreateObject("Scripting.FileSystemObject")
   If oFS.FileExists(sFilePathAndName) = True Then        
      Set oTextStream = oFS.OpenTextFile(sFilePathAndName,1)
      sFileContents = oTextStream.ReadAll
      oTextStream.Close
      Set oTextStream = nothing
   End if
   Set oFS = nothing
   ReadFile = sFileContents
End Function
0
 

Author Comment

by:Hojoformo
ID: 17958838
Thanks Amit.  I have a question.  Will this work for file in internal storage?  For example, if I want just send data that I created inside the program like this - Base64Data

Base64Data = Base64EncodeBinary(oXML.xml)

Call Response.Clear()
Response.ContentType = "application/x-unknown"
Call Response.AddHeader("Content-Disposition", "attachment; filename=Base64Data")
Call Response.Write(ReadFile(Base64Data))   ???  will this work?
Call Response.End()

0
 
LVL 58

Accepted Solution

by:
amit_g earned 500 total points
ID: 17963291
>> Call Response.Write(ReadFile(Base64Data))   ???  will this work?

No but since you already have it in a variable, you should instead do

Call Response.Write(Base64Data)

and that should work.
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 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