|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Article Discussion: FTP段ng Files with ASP
Would you like the ability to transfer files from your ASP app with the greatest of ease? Forget downloading and installing server-side components forget spending money. Forget inefficient and/or cryptic coding! This article demonstrates how easy it is to embed file transfer functionality into your application.
Read the full article here: FTP段ng Files with ASP |
|
#2
|
|||
|
|||
|
ftp files in asp
have anyone used tried this?
where to put the strCommands? and where do i activate the missing ocx? if anyone have a real example... please send me some explanation of how to implement. i always get trouble with this: set WSX = objShell.Exec( FTP_CMD & strScriptName & " " & Host ) where is the strScriptname declared?, and the ftp_cmd...is it right? need help URL |
|
#3
|
|||
|
|||
|
can this be used with an upload form?
Would this be a viable alternative to aspUpload? Would there be security issues if the account had write only permissions and you limited the file extensions allowed for upload? I'm very interested in replacing aspUpload because it often fails with larger files. |
|
#4
|
||||
|
||||
|
sorry, the line should really be:
set WSX = objShell.Exec( COMMAND_FTP & strFile & " " & strHost ) I forgot this one line when trying to make my variables more human readable for the purpose of writing the article. It just so happens that this is the most crucial line :P The real use of this is transferring files from the SERVER to another SERVER, not from your client machine to the server. Because of this, it would not replace ASPUpload. ASPUpload would be limited by the natural limits of a POST method (a few megabytes) |
|
#5
|
|||
|
|||
|
Would you mind sending me this file???
|
|
#6
|
||||
|
||||
|
It is attached to this reply
|
|
#7
|
|||
|
|||
|
Thanks!
|
|
#8
|
|||
|
|||
|
I am getting a Permission denied error at this line, "Set objFile = objFSO.OpenTextFile(sErrorLog, 2, True )"
sErrorLog is set as "sErrorLog = objTempFldr.Path & "ftpErrors.txt"" |
|
#9
|
||||
|
||||
|
Quote:
__________________
selwonk If I've posted some code above, you might think it looks a bit simplistic. It might be. I'd rather people tried the next step themselves rather than getting a full solution on a plate. That way they learn more! |
|
#11
|
||||
|
||||
|
Post your code...
|
|
#12
|
|||
|
|||
|
My Code
<%@ Language=VBScript %>
<% Dim strHost, strUser, strPass, strMode, LocalDir, RemoteDir Dim Output, ReturnCode, strScript Const COMMAND_FTP = "ftp.exe -i -s:" strHost = "myftpbox" strUser = "user" strPass = "pass" strMode = "ascii" '=== "ascii" / "binary" LocalDir = "C:\test" RemoteDir = "/test/" '===================== Function FTP( strCMD ) '===================== '=== Build a command script, FTPs with it, deletes it Dim objFSO, strFile, objTempFldr, objFile, objRegExp Dim objShell, WSX, ReturnCode, Output, strLog, strErrorLog Set objFSO = CreateObject("Scripting.FileSystemObject") set objTempFldr = objFSO.GetSpecialFolder( 2 ) strFile = objFSO.GetTempName strFile = objTempFldr & "" & strFile & ".ftp" if not objFSO.FileExists( strFile ) then objFSO.CreateTextFile( strFile ) Set objFile = objFSO.OpenTextFile( strFile, 2, True ) objFile.WriteLine( strUser ) objFile.WriteLine( strPass ) If LocalDir <> "" Then objFile.WriteLine( "lcd " & LocalDir ) If RemoteDir <> "" Then objFile.WriteLine( "cd " & RemoteDir ) objFile.WriteLine( Mode ) objFile.WriteLine( strCMD ) objFile.WriteLine( "bye" ) objFile.Close() Set objShell = Server.CreateObject("WScript.Shell") set WSX = objShell.Exec( COMMAND_FTP & strFile & " " & strHost ) 'set WSX = objShell.Exec( FTP_CMD & strScriptName & " " & Host ) set ReturnCode = WSX.StdErr set Output = WSX.stdOut strErrorLog = objTempFldr.Path & "ftpErrors.txt" strLog = objTempFldr.Path & "ftpLog.txt" Set objFile = objFSO.OpenTextFile( strErrorLog, 2, True ) objFile.Write( ReturnCode.ReadAll() ) objFile.Close() Set objFile = objFSO.OpenTextFile( strLog, 2, True ) objFile.Write( Output.ReadAll() ) objFile.Close() set objFSO = nothing set objFile = nothing objFSO.DeleteFile strFile, True set objFSO = nothing Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Pattern = "not connected|invalid command|error" If (objRegExp.Test( Output.ReadAll ) = True ) Or(objRegExp.Test( ReturnCode.ReadAll ) ) Then 'on one line FTP = False Else FTP = True End If Set objRegExp = nothing End Function %> <html> <head> <title> My Test FTP </title> </head> <body> FTP <% Dim strCommands strCommands = "PUT test.doc" FTP(strCommands) %> </body> </html> |
|
#13
|
||||
|
||||
|
You already appear to be doing this?
Code:
<% Dim strCommands strCommands = "PUT test.doc" FTP(strCommands) %> |
|
#14
|
|||
|
|||
|
Yeah I kind of figured that out before I posted my code to you. Do you know
why I might be getting the following error? Error Type: Microsoft VBScript runtime (0x800A01A8) Object required: 'objFSO' /ftp.asp, line 59 |
|
#15
|
|||
|
|||
|
no PASV with ftp.exe
Ftp.exe does not support PASV mode transfers through firewalls. Any work around or other ftp implementations?
thanks. |
![]() |
| Viewing: ASP Free Forums > Other > Development Articles > Article Discussion: FTP段ng Files with ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|