Android Question [SOLVED] Read all the .jpg files from a remote folder

desof

Well-Known Member
Licensed User
Longtime User
In what way can I read all the jpg files that are in a certain remote folder?
I think in this Sub you should do it

B4X:
Public Sub FindImages (root As String) As ResumableSub
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download(root)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Dim str As String = j.GetString
        Dim rb As RegexBuilder
        rb.Initialize
        rb.AppendEscaped("<img").Append(rb.CharAny).AppendZeroOrMore.AppendEscaped($"src=""$).StartCapture
        rb.AppendAnyBut(Array($"""$)).AppendAtLeastOne.EndCapture.Append(rb.CharQuote)
        Log(rb.Pattern)
        Dim m As Matcher = Regex.Matcher2(rb.Pattern, Regex.MULTILINE, str)
        Do While m.Find
            Dim link As String = m.Group(1)
            If link.StartsWith("http") = False Then
                If link.StartsWith("/") = False Then link = "/" & link
                link = root & link
            End If
            Main.urls.Add(link)
        Loop
    End If
    j.Release
    Return j.Success
End Sub
 

Peter Simpson

Expert
Licensed User
Longtime User
Hmm, this may be of some help to you. With just a small change of code this should do exactly what you are looking for...
 
Upvote 0

desof

Well-Known Member
Licensed User
Longtime User
[QUOTE = "Peter Simpson, publicación: 605277, miembro: 21400"] Hmm, esto puede ser de alguna ayuda para usted. Con solo un pequeño cambio de código, debería hacer exactamente lo que está buscando ...
[MEDIA = vimeo] 255570732 [/ MEDIA] [/ QUOTE]

I have watched the 30 minutes and it has nothing to do with what I am requesting.
I just want to get a list of images from a remote folder
 
Upvote 0

FrankDev

Active Member
Licensed User
Longtime User
you need a script to display the files?

B4X:
<?php
$alledateien = scandir('files'); //Ordner "files" auslesen
 
foreach ($alledateien as $datei) { // Ausgabeschleife
   echo $datei."<br />"; //Ausgabe Einzeldatei
};
 echo "ende";
?>

regards Frank
 
Upvote 0

desof

Well-Known Member
Licensed User
Longtime User
[QUOTE = "Erel, post: 605359, member: 1"] ¿Qué quiere decir con una carpeta remota? ¿Es esto un servidor FTP? SMB? [/ QUOTE]

In your example you helped me you have a link on line 39 of the Main
https://www.b4x.com/android/forum/t...sing-when-the-slider-is-on.95779/#post-604705 (# 2)

OK!
B4X:
Wait For (CallSub2(Starter, "FindImages", "https://www.b4x.com")) Complete (Success As Boolean)

NOT FOUND
B4X:
Wait For (CallSub2(Starter, "FindImages", "https://www.desoft.com.ar/sancrisapp/fotos")) Complete (Success As Boolean)

and I change the link to direct to my server and it does not work because it does not read the images.

Attached I capture my image
 

Attachments

  • temp.jpg
    temp.jpg
    49.9 KB · Views: 260
Last edited:
Upvote 0

Addo

Well-Known Member
Licensed User
Longtime User
[QUOTE = "Erel, post: 605359, member: 1"] ¿Qué quiere decir con una carpeta remota? ¿Es esto un servidor FTP? SMB? [/ QUOTE]

In your example you helped me you have a link on line 39 of the Main
https://www.b4x.com/android/forum/t...sing-when-the-slider-is-on.95779/#post-604705 (# 2)

OK!
B4X:
Wait For (CallSub2(Starter, "FindImages", "https://www.b4x.com")) Complete (Success As Boolean)

NOT FOUND
B4X:
Wait For (CallSub2(Starter, "FindImages", "https://www.desoft.com.ar/sancrisapp/fotos")) Complete (Success As Boolean)

and I change the link to direct to my server and it does not work because it does not read the images.

Attached I capture my image

as i can see you have a bunch of images in your ftp that you want to download them all into your android device ?

if yes then you need to create a php file to read those files in a url look at the replay above for php code

then in b4a you should get this php content strings to a list and use okhttp to download each item based on your website url

https://www.b4x.com/android/forum/threads/b4x-okhttputils2-with-wait-for.79345/
 
Upvote 0

asales

Expert
Licensed User
Longtime User
B4X:
Wait For (CallSub2(Starter, "FindImages", "https://www.b4x.com")) Complete (Success As Boolean)
This code read the images from a index.html file, like this:
B4X:
 <!DOCTYPE html>
<html>
<body>

<img src="1.jpg">
<img src="2.jpg">
<img src="3.jpg">
<img src="4.jpg">
<img src="10.jpg">
<img src="20.jpg">
<img src="myimage27.jpg">
<img src="myimage26.jpg">
<img src="myimage25.jpg">
 
</body>
</html>
If you create a index.html with the names of your images (1.jpg, 10.jpg) and put the file in the folder, the code will read the images and show it in the slider.
 
Upvote 0

desof

Well-Known Member
Licensed User
Longtime User
This code read the images from a index.html file, like this:
B4X:
 <!DOCTYPE html>
<html>
<body>

<img src="1.jpg">
<img src="2.jpg">
<img src="3.jpg">
<img src="4.jpg">
<img src="10.jpg">
<img src="20.jpg">
<img src="myimage27.jpg">
<img src="myimage26.jpg">
<img src="myimage25.jpg">
 
</body>
</html>
If you create a index.html with the names of your images (1.jpg, 10.jpg) and put the file in the folder, the code will read the images and show it in the slider.
thank you very much that's what I was missing so that my images can be read.
 
Upvote 0
Top