Page 1 of 1

can i read local server file ?

Posted: Wed Oct 19, 2016 3:28 pm
by skinkairewalker
hi , i am trying read some file .txt in local server ... but when i call command > readString , dont get any string ...

Re: can i read local server file ?

Posted: Wed Oct 19, 2016 4:49 pm
by Peter
skinkairewalker wrote:hi , i am trying read some file .txt in local server ...
this doesn't work with JavaScript. You need to call a server-side script.

SB-Code (from SB-Help):

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://localhost/readfile/readfile.php", "", @HttpGetEvent())
readfile.php (runs on your Server):

Code: Select all

<?php
header('Access-Control-Allow-Origin: http://127.0.0.1:9080');
echo file_get_contents("test.txt");
?>
Greetings ... Peter

Re: can i read local server file ?

Posted: Fri Oct 21, 2016 2:35 pm
by skinkairewalker
thanks peter ^^