Sub btTest_Click 'ListFiles (Dir As String) As List
ImageFolder2 = File.DirRootExternal & "/Test1/"
Files.Initialize
Files = File.ListFiles(ImageFolder2)
Files.SortCaseInsensitive(True)
FTP.List("public_html/Test2/")
FTP.PassiveMode = True
End Sub
Sub FTP_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
Dim s As String
s = "public_html/Test2/" & Round(TotalDownloaded / 1000) & "KB"
If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
Log(s)
End Sub
Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
Log(ServerPath & ", Success=" & Success)
If Success = False Then Log(LastException.Message)
End Sub
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
Log(ServerPath)
If Success = False Then
Log(LastException)
Else
For i = 0 To Folders.Length - 1
Log(Folders(i).Name)
Next
For i = 0 To Files.Length - 1
Log(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp))
Next
End If
End Sub
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim FTP As FTP
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.Title= "Use the Menu to List the Files"
Activity.AddMenuItem("LIST FILES","menuLIST")
End Sub
Sub Activity_Resume
If FTP.IsInitialized Then FTP.closenow
FTP.Initialize("FTP", "FTP.secureftp-test.com", 21, "test", "test")
End Sub
Sub Activity_Pause (UserClosed As Boolean)
FTP.Close
End Sub
Sub menuLIST_Click
ToastMessageShow("Checking for FTP List now",False)
FTP.PassiveMode = True
FTP.List("./")
End Sub
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
Log(ServerPath)
If Success = False Then
Log(LastException)
Else
For i = 0 To Folders.Length - 1
ToastMessageShow(Folders(i).Name,False)
Log(Folders(i).Name)
Next
For i = 0 To Files.Length - 1
Log(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp))
ToastMessageShow(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp),False)
Next
End If
End Sub
Compiling code. Error
Error parsing program.
Error description: Parameter name cannot hide global variable name.
Occurred on line: 113
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim FTP As FTP
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim btn_download As Button
Dim btn_list As Button
Dim btn_Upload As Button
Dim Button1 As Button
Dim Button2 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
End Sub
Sub Activity_Resume
FTP.Initialize("FTP", "FTP.secureftp-test.com", 21, "test", "test")
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub FTP_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
Dim s As String
s = "Downloaded " & Round(TotalDownloaded / 1000) & "KB"
If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
Log(s)
End Sub
Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
Log(ServerPath & ", Success=" & Success)
If Success = False Then Log(LastException.Message)
End Sub
Sub btn_download_Click
FTP.PassiveMode = True
msgbox("File will be stored in: " & File.DirRootExternal,"")
FTP.DownloadFile("hamlet.zip", False, File.DirRootExternal, "999999999999.zip")
End Sub
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
If Success == False Then
Log(LastException.Message)
Else
For i = 0 To Files.Length - 1
Log(Files(i).Name)
Next
For i = 0 To Folders.Length - 1
Log(Folders(i).Name)
Next
End If
End Sub
FTP.DownloadFile("hamlet.zip", False, File.DirRootExternal, "999999999999.zip")
FTP.DownloadFile(".jpg", False, File.DirRootExternal, ".jpg")
Sub Process_Globals
Dim FTP As FTP
End Sub
Sub Globals
Dim btn_download As Button
Dim btn_list As Button
Dim btn_Upload As Button
Dim Button1 As Button
Dim Button2 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.Title= "Use the Menu to Download the JPG Files"
Activity.AddMenuItem("Download JPG Files","menuLIST")
End Sub
Sub Activity_Resume
If FTP.IsInitialized Then FTP.closenow
FTP.Initialize("FTP", "FTP.secureftp-test.com", 21, "test", "test")
End Sub
Sub Activity_Pause (UserClosed As Boolean)
FTP.Close
End Sub
Sub menuLIST_Click
Msgbox("File will be stored in: " & File.DirRootExternal,"")
ToastMessageShow("Checking for FTP List now",False)
FTP.PassiveMode = True
FTP.List("./")
End Sub
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
Log(ServerPath)
If Success = False Then
Log(LastException)
Else
For i = 0 To Folders.Length - 1
ToastMessageShow(Folders(i).Name,False)
Log(Folders(i).Name)
Next
For i = 0 To Files.Length - 1
Log(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp))
ToastMessageShow(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp),False)
If Files(i).Name.EndsWith(".xml") Then FTP.DownloadFile(Files(i).Name, False, File.DirRootExternal, Files(i).Name)
Next
End If
End Sub
Sub FTP_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
Dim s As String
s = "Downloaded " & Round(TotalDownloaded / 1000) & "KB"
If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
Log(s)
End Sub
Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
Log(ServerPath & ", Success=" & Success)
If Success = False Then Log(LastException.Message)
End Sub
Installing file.
PackageAdded: package:B4A.FTP
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
public_html/test/
.
..
Morgan-EvaGT_2012.jpg, 50358, 12/20/2011
caterham.jpg, 94549, 12/20/2011
mercedes CLife.jpg, 41679, 12/20/2011
public_html/test/, Success=false
java.lang.RuntimeException: Error retrieving file.
550 I can only retrieve regular files
public_html/test/, Success=false
java.lang.RuntimeException: Error retrieving file.
550 I can only retrieve regular files
public_html/test/, Success=false
java.lang.RuntimeException: Error retrieving file.
550 I can only retrieve regular files
** Activity (main) Pause, UserClosed = true **
:sign0148:FTP can only retrieve or send single files with each RETR/STOR command. Usually works like this:
1. The client changes into the directory using the CWD command, then checks if the directory change was successful (PWD).
2. The client retrieves a listing of all objects in that directory (using LIST, or the more preferred MLSD, if supported).
3. The client then must parse the received listing for the files it desires and put them into a sort of queue.
4. Then it generates one RETR/STOR command per file and processes them in a batch style (either immediately or after having parsed all directories).
5. For recursivity, 1-4 must be repeated for each directory in the tree.
If Files(i).Name.EndsWith(".jpg") Then
FTP.SendCommand("binary")
FTP.DownloadFile(Files(i).Name, False, File.DirRootExternal, Files(i).Name)
end if
I believe that the code does/will work for you
You can add
B4X:If Files(i).Name.EndsWith(".jpg") Then FTP.SendCommand("binary") FTP.DownloadFile(Files(i).Name, False, File.DirRootExternal, Files(i).Name) end if
Since you said the jpg file was empty
ftp> mget *.jpg
With mget you can download multiple images. This command downloads all files that end with ".jpg".
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?