?
Solved

Write ftp a file from a classic ASP program

Posted on 2006-11-15
4
Medium Priority
?
1,135 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

741 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