ASP
  Home arrow ASP arrow Page 2 - FTP’ing Files with ASP
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

FTP’ing Files with ASP
By: Justin Cook
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 176
    2004-01-21

    Table of Contents:
  • FTP’ing Files with ASP
  • Variable: Having No Fixed Quantitative Value
  • The Great FTP Function
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    FTP’ing Files with ASP - Variable: Having No Fixed Quantitative Value


    (Page 2 of 4 )

    The very first thing I do is create an ftp.asp file, and all the coding will go in there. Then wherever we need to make use of the wonder-function, we just include the page into whatever file we’re working with. (<!--#include virtual="/includes/ftp.asp"--> )

    Let’s start working with ftp.asp. First, we declare our variables:


    Dim strHoststrUserstrPassstrModeLocalDirRemoteDir
    Dim Output
    ReturnCodestrScript
    Const COMMAND_FTP "ftp.exe -i -s:"

    Most of the variable will be set, but are purposefully variable. This is in case we want to use the scrip for more that one host or file, as I will explain later on.

    The only constant is COMMAND_FTP. This is to prevent errors, as we should only ever need to use it with the ‘-i’ switch (disables multiple file transfer prompting) and the ‘–s:’ switch (indicates a text file containing the FTP commands).

    Here are some initial values for the other variables:


    strHost "mydomain.com"
    strUser 
    "ftpadmin"
    strPass 
    "myPassword"
    strMode 
    "ascii" '=== "ascii" / "binary" 
    LocalDir = Request.ServerVariables("APPL_PHYSICAL_PATH") & "published"
    RemoteDir = "/public_html/"

    Now these are just the initial settings, preferably set to provide for your most common use within the application. But chances are you will want to make use of FTP for something uncommon, and in that case it would be an absolute pain in the butt to have to duplicate all the code for one use. So, we would quite simply just reset a variable or two after including the page (they are variables after all!). This would not affect the default values anywhere else the page is included. This means that we could bastardize these variants however we chose, and they’d be right back to their glorious selves the next time the page is requested! Here’s an example:


    strMode “binary”
    LocalDir 
    “C:MyBabyPictures”
    RemoteDir 
    /outgoing/

    This would be handy if we have an image or a zip file or anything really that needs to be thrown somewhere, anywhere, you name it!

    Ok, enough with that, I wish not to be accused of beating a deceased Equus caballus. Let us move onto greater things!

    More ASP Articles
    More By Justin Cook


       · Thank you very much for your spectacular and entertaining code!However, I don't...
       · When you use FTP from the command prompt, it runs from the currently selected local...
     

    ASP ARTICLES

    - Using MySQL with ASP
    - ADO for the Beginner
    - ADO.NET 101: Data Rendering with a DataGrid ...
    - Introducing SoftArtisans OfficeWriter 3.0 En...
    - Getting Remote Files With ASP
    - The Real Basics of Functions in ASP
    - Enhancing Readability with ASP
    - Mimicking PHP's String Formatting Functions
    - Windows Server Hacks 12, 77, and 98
    - How to Sort a Multi-Dimensional Array
    - Developing an Information Management Tool wi...
    - What are Active Server Pages?
    - Getting Remote Pages with ASP
    - FTP’ing Files with ASP
    - Apply Single-Sign-On to Your Application

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT