Free and shareware Components


Download Products


DypsWebCapture : Capture Web page as thumbnail image

Documentation
Example
Download
Buy

New release with embed IE and Firefox rendering engine !



DypsFTP : Manage a FTP site from your script

Documentation
Buy


DypsImg2SWF : Protect and save your image as SWF/Flash format!

Documentation
Example
Download
Buy


DypsXLS for ASP: Générateur de fichier Excel

New features!
Documentation
Exemple d'utilisation
Download
Buy


DypsMetaGrabber : get Meta Tag from any web page!

Documentation
Example
Download
Buy


DypsAntiSpam for ASP

Features
Exemple d'utilisation
Download
Buy

DypsoPRank for ASP

Features
Exemple d'utilisation
Download
Buy

Pop3 Checker for ASP

Features
Exemple d'utilisation
Download
Buy

SVG Pie chart Maker for ASP

Features
Exemple d'utilisation
Download

DypsRTF for ASP

Features
Exemple d'utilisation
Download
Buy

What's New ?


Mise en ligne du premier outil gratuit pour générer des fichiers Excel depuis ASP : DypsXLS !
[Lire la suite]

Et un forum Le site se dote d'un forum pour vous permettre de partager toujours plus.
[Rejoigner nous]

Annuaire de scripts ! Un annuaire de scripts et de liens utiles vers des ressources pour le développement
[Lire la suite]

Création d'un outil gratuit pour retrouver ses mails : Pop3 Checker for free !
[Lire la suite]

Création d'un outil gratuit pour générer des graphiques vectoriels à la volée: Free SVG Pie chart Maker !
[Lire la suite]
Print friendly

How to retrieve a remote file on a FTP server without any third-party components

Techniques

This section makes it possible to gather a whole of techniques or scripts which have the originality to manage to solve a difficulty with the least effort or which are particularly effective...The grayed entries relate to the future headings which will supplement soon this toolbox.

' Script original : FTP via ASP without using 3rd-party components ' Ben Meghreblian 15th Jan 2002 ' benmeg at benmeg dot com / http://benmeg.com


Techniques / FTP via ASP without using any 3rd-party components
Please visit our sponsors

  •  How to retrieve a remote file vie ASP and FTP without using a 3rd-party component :


This tutorial is aimed to show you how it is possible to retrieve a remote file via ASP and FTP without using a 3rd-party component. Windows plateform usually come with FTP.exe which is located in folder : C:\WINNT\system32. This utility can be drive from dos command line in order to connect to a FTP server,browse a FTP Directory, download and put file in the FTP site.

This script supposed that the file to upload from the ftp server will be upload in the current directory. You could also use joker for the function ftp_files_to_put as *.txt for exemple.

In order to launch and execute the command line for ftp.exe, it's the activeX wshom.ocx which will be used. It is generally stored at this location : c:\winnt\system32\wshom.ocx. Just be sure that it is registred on the system ( for that type from the command line : "regsvr32 c:\winnt\system32\wshom.ocx")

In the following example the ftp commands are written in a text file and then are executed on the fly thanks to the activeX wshom :

	
 <%

Dim objFSO, objTextFile, oScript, oScriptNet
Dim oFileSys, oFile, strCMD, strTempFile, strCommandResult
Dim ftp_address, ftp_username, ftp_password
Dim ftp_physical_path, ftp_files_to_put

' Put your values
ftp_address          = "ftp.server.com"
ftp_username         = "username"
ftp_password         = "password"

' let it empty if the file is in the ftp root
ftp_remote_directory = "subdirectory" 



ftp_files_to_put     = "file.txt"

On Error Resume Next
Set oScript = Server.CreateObject("WSCRIPT.SHELL")
Set oFileSys = 
	Server.CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Write the ftp commands
Set objTextFile=objFSO.CreateTextFile
	(Server.MapPath("test.ftp"))
objTextFile.WriteLine "lcd " & Server.MapPath(".")
objTextFile.WriteLine "open " & ftp_address
objTextFile.WriteLine ftp_username
objTextFile.WriteLine ftp_password

' Verify if we have to do a cd 
If ftp_remote_directory <> "" Then
   objTextFile.WriteLine "cd " & ftp_remote_directory
End If

objTextFile.WriteLine "prompt"

' Write this line if the file is a binary one(image,...)
' objTextFile.WriteLine "binary"


'With multiple files use mput 
' instead of put
If Instr(1, ftp_files_to_put, "*",1) Then
   objTextFile.WriteLine "mput " & ftp_files_to_put
Else
   objTextFile.WriteLine "put " & ftp_files_to_put
End If
objTextFile.WriteLine "bye"
objTextFile.Close
Set objTextFile = Nothing


' Launch ftp.exe on 
' the command line
strCMD = "ftp.exe -s:" & Server.MapPath("test.ftp")
strTempFile = "C:\" & oFileSys.GetTempName( )


Call oScript.Run
   ("cmd.exe /c " & strCMD & " > " & strTempFile, 0, True)
Set oFile = oFileSys.OpenTextFile (strTempFile, 1, False, 0)

On Error Resume Next

' We save the result of the command
' in a temporary file

strCommandResult = Server.HTMLEncode( oFile.ReadAll )
oFile.Close

' We delete the temporary file and the commands
Call oFileSys.DeleteFile( strTempFile, True )
Call objFSO.DeleteFile( Server.MapPath("test.ftp"), True )
Set oFileSys = Nothing
Set objFSO = Nothing

' We write out the result of the ftp commands
Response.Write(Replace( strCommandResult, vbCrLf, "
", 1, -1, 1)) %>
Related Links

A question ? Use the forum !.