cancel
Showing results for 
Search instead for 
Did you mean: 

Updating a .txt file with php

timkudla
Participant
0 Kudos

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) :

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

Secondly the call from Javascript:

writeStringToFile: function(newContent){		   
		    
     $.ajax({
	url: "writeFile.php",
        type: "GET",
        data: newContent,
	async: true,
	success: function(data){
	    console.log("Success");
	}
      });
}

Thanks in advance!

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

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

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL|E_STRICT);

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

timkudla
Participant
0 Kudos

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