Was hoping to submit this FTP Upload Script as a sample / script of the month entry, however have had a blonde moment (not even blonde) and lack of time at present.
I have the single upload working, I was trying to get the multiple folder upload to work, however couldn't work out what I was missing to have it upload the entire contents of the folder and use the folder name (while allowing it to support the upload path).
Any Help Appreciated.
![Image](http://i.minus.com/i5Jbw4LHxTNZc.gif)
Code: Select all
Let>APP_TITLE=FTP Upload Sample v1.0
Let>MSG_HEIGHT=320
Let>MSG_WIDTH=500
Let>MSG_STAYONTOP=1
Let>MSG_CENTERED=1
Dialog>Dialog1
object Dialog1: TForm
Left = 247
Top = 96
HelpContext = 5000
BorderIcons = [biSystemMenu]
BorderStyle = bsSingle
Caption = 'CustomDialog'
ClientHeight = 241
ClientWidth = 267
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
Position = poScreenCenter
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object Label2: TLabel
Left = 8
Top = 8
Width = 71
Height = 13
Caption = 'FTP Hostname'
end
object Label3: TLabel
Left = 200
Top = 8
Width = 42
Height = 13
Caption = 'FTP Port'
end
object Label4: TLabel
Left = 8
Top = 48
Width = 71
Height = 13
Caption = 'FTP Username'
end
object Label5: TLabel
Left = 136
Top = 48
Width = 69
Height = 13
Caption = 'FTP Password'
end
object Label6: TLabel
Left = 8
Top = 128
Width = 142
Height = 13
Caption = 'Files / Folder To Be Uploaded'
end
object Label7: TLabel
Left = 8
Top = 168
Width = 101
Height = 13
Caption = 'FTP Upload Location'
end
object FTPHOSTNAME: TEdit
Left = 8
Top = 24
Width = 185
Height = 21
Hint =
'If you are connecting via a proxy server,'#13#10'enter the name or IP ' +
'address of the proxy'#13#10'server in '#39'Server'#39', and for '#39'Username'#39#13#10'sp' +
'ecify username@remote_server.'
TabOrder = 0
end
object FTPPort: TEdit
Left = 200
Top = 24
Width = 57
Height = 21
TabOrder = 1
Text = '21'
end
object FTPUSERNAME: TEdit
Left = 8
Top = 64
Width = 121
Height = 21
Hint =
'If you are connecting via a proxy server,'#13#10'enter the name or IP ' +
'address of the proxy'#13#10'server in '#39'Server'#39', and for '#39'Username'#39#13#10'sp' +
'ecify username@remote_server.'
TabOrder = 2
end
object FTPPASSWORD: TEdit
Left = 136
Top = 64
Width = 121
Height = 21
PasswordChar = '*'
TabOrder = 3
end
object MSButton1: tMSButton
Left = 104
Top = 208
Width = 75
Height = 25
Caption = 'Upload'
TabOrder = 8
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton2: tMSButton
Left = 184
Top = 208
Width = 75
Height = 25
Caption = 'Exit'
ModalResult = 2
TabOrder = 9
DoBrowse = False
BrowseStyle = fbOpen
end
object UploadType: tMSRadioGroup
Left = 9
Top = 90
Width = 248
Height = 31
Caption = 'Select Upload Type'
Columns = 2
ItemIndex = 0
Items.Strings = (
'Single File'
'Folder')
TabOrder = 4
Text = 'Single File'#13#10'Folder'#13#10
end
object SELECTEDUPLOAD: TEdit
Left = 8
Top = 144
Width = 185
Height = 21
TabOrder = 5
end
object MSButton3: tMSButton
Left = 201
Top = 141
Width = 56
Height = 25
Caption = 'Browse'
Default = True
TabOrder = 6
DoBrowse = False
BrowseStyle = fbOpen
end
object UPLOADPATH: TEdit
Left = 8
Top = 184
Width = 249
Height = 21
TabOrder = 7
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,MSButton3,OnClick,FILESELECT
AddDialogHandler>Dialog1,MSButton2,OnClick,EXIT
AddDialogHandler>Dialog1,MSButton1,OnClick,UPLOADFILES
SetDialogProperty>Dialog1,,Caption,%APP_TITLE%
SetDialogProperty>Dialog1,,Position,poScreenCenter
Show>Dialog1,Dialog1Result
SRT>FILESELECT
GetDialogProperty>Dialog1,UploadType,ItemIndex,TYPESELECTVALUE
If>%TYPESELECTVALUE%=0
SetDialogProperty>Dialog1,MSButton3,BrowseStyle,fbOpen
SetDialogProperty>Dialog1,MSButton3,DoBrowse,True
EndIf
If>%TYPESELECTVALUE%=1
SetDialogProperty>Dialog1,MSButton3,BrowseStyle,fbFolder
SetDialogProperty>Dialog1,MSButton3,DoBrowse,True
EndIf
GetDialogProperty>Dialog1,MSButton3,Filename,File2Copy
SetDialogProperty>Dialog1,SELECTEDUPLOAD,Text,File2Copy
END>FILESELECT
SRT>UPLOADFILES
GetDialogProperty>Dialog1,FTPHOSTNAME,Text,HOSTNAME
GetDialogProperty>Dialog1,FTPPort,Text,PORT
GetDialogProperty>Dialog1,FTPUSERNAME,Text,USERNAME
GetDialogProperty>Dialog1,FTPPASSWORD,Text,PASSWORD
GetDialogProperty>Dialog1,SELECTEDUPLOAD,Text,2UPLOAD
GetDialogProperty>Dialog1,UPLOADPATH,Text,WHERE2UPLOAD
If>%TYPESELECTVALUE%=0
FTPPutFile>%HOSTNAME%,%USERNAME%,%PASSWORD%,%PORT%,%2UPLOAD%,%WHERE2UPLOAD%,,I
EndIf
If>%TYPESELECTVALUE%=1
Separate>2UPLOAD,\,2UPLOAD
Let>FTPFolder=2UPLOAD_%2UPLOAD_COUNT%
FTPMakeDir>%HOSTNAME%,%USERNAME%,%PASSWORD%,%PORT%,%WHERE2UPLOAD%/%FTPFolder%
FTPPutFile>%HOSTNAME%,%USERNAME%,%PASSWORD%,%PORT%,%2UPLOAD%\*.*,/%FTPFolder%/,,I
EndIf
MDL>FTP Upload Status / Result: %FTP_RESULT%%CRLF%%CRLF%Number Of Files Uploaded: %FTP_NUMFILES%
END>UPLOADFILES
SRT>EXIT
Exit>0
END>EXIT