Page 1 of 1
Read all files in a directory
Posted: Wed Mar 19, 2025 5:16 pm
by Stefan
I want to read all the files in a directory.
I found this PHP code for that.
Code: Select all
<?php
foreach (glob("*.*") as $filename) {
echo "$filename - Größe: " . filesize($filename) . "\n";
}
?>
But how do I retrieve the result in SpiderBasic?
Re: Read all files in a directory
Posted: Thu Mar 20, 2025 1:42 am
by plouf
php code runs in a webserver, so this code must located in webserver , you call like any other page i.e
if for example i want to execute an example.php script located in webserver
HTTPRequest(#PB_HTTP_Get, "
http://www.stefan.com/example.php, "", @callbackHttpGetEvent())
callback will receive php exported data
keep in mind that it will list directory of local webserver php is running to
Re: Read all files in a directory
Posted: Thu Mar 20, 2025 8:35 am
by Stefan
That's exactly what it's about

I don't know how to read the data in callbackHttpGetEvent()

Re: Read all files in a directory
Posted: Thu Mar 20, 2025 8:42 am
by plouf
Http request has an example ,
Code: Select all
Procedure HttpGetEvent(Success, Result$, UserData)
If Success
Debug Result$
Else
Debug "HTTPRequest(): Error"
EndIf
EndProcedure
; Get the content of this file, and display it in the debug window
;
HTTPRequest(#PB_HTTP_Get, "http://www.stefan.com/phpscript.php, "", @HttpGetEvent())
https://www.spiderbasic.com/documentati ... quest.html
Note that sb script MUST be in
www.stefan.com url AND executed from a webbrowser
Re: Read all files in a directory
Posted: Thu Mar 20, 2025 11:14 am
by Stefan
Great!
Thank you so much!
