Skip to Content

Updating a .txt file with php

Nov 28, 2016 at 08:29 AM


avatar image

Hello community,

I want to create an app with the HANA WebIDE that read/write some data to an .txt file.

After reading that some people run php scripts with SAPUI5 I test this, but in my case it doesn´t work.

I hope somebody find my mistake and have a suitable solution, because other community discussions aren´t so helpful.

First the php file (writeFile.php) :

function phpAlert($msg) {
    $content= "123456789";
    $handle = fopen ("testWrite.txt", w);
    fwrite ($handle, $content);
    fclose ($handle);

Secondly the call from Javascript:

writeStringToFile: function(newContent){		   
	url: "writeFile.php",
        type: "GET",
        data: newContent,
	async: true,
	success: function(data){

Thanks in advance!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Ulrich Block
Nov 28, 2016 at 08:45 AM

Besides you should add input validation, an active debugger might help giving you pointers:

ini_set('display_errors', 1);

Depending of the webservers configuration required PHP functions might be disabled or other permissions are not configured properly.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Unfortunately I have no knowledge about php, so that I don´t know what should happen when your code runs. I integrate it in the script, but in the console of Chrome was nothing displayed except the console.log statement