Solved

Write ftp a file from a classic ASP program

Posted on 2006-11-15
4
1,118 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
  • 2
4 Comments
 
LVL 25

Expert Comment

by:kevp75
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
>> 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Summer note focus on load 19 185
ASP equivalent to Windows findstr 3 59
Out the count variables 6 47
CSS Question.. 3 72
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now