So basically I am trying to send data to a textfile in raspberrypi(apache server) from my ESP01 using AT-Commands. I am trying to use POST method of apache for same. Here is my PHP code:
`<?php
$tempF=$_POST["temp"];
$file='testfile.text';
$myfile=($file,"w+");
fwrite($myfile,$tempF);
fclose($myfile);
?>`
Here is the data I send through AT Command (AT+CIPSEND)
`POST /TEMP/post.php HTTP/1.1\r\nHost: 192.168.0.138:80\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length:9 \r\n\r\ntemp=1234`
So when I send this AT command, I assume that php file should be executed and data from 'temp' variable should be written to the text file. However there is no such output visible nor any errors displayed.
Here is simple map of how paths are placed root folder:/var/www/html inside it -> TEMP(folder), index.html inside TEMP -> post.php, testfile.txt
I have already tried following :
P.S. I am new to PHP and POST method of HTTP/1.1
Thanks☻
EDIT 1: As from Juraj's comment I realised that when you send \r\n through serial monitor it actually sends \n and so I tried the conventional method while entering Post Command as follows:
POST /TEMP/post.php HTTP/1.1
Host: 192.168.0.138:80
Content-Type: application/x-www-form-urlencoded
Content-Length:9
temp=1234
And I recieved following Error:
+IPD,187:HTTP/1.0 500 Internal Server Error
Date: Fri, 06 Aug 2021 13:06:57 GMT
Server: Apache/2.4.38 (Raspbian)
Content-Length: 0
Connection: close
Content-Type: text/html; charset=UTF-8
Update:
While searching for same, I found reqbin.com which helps to test POST/GET methods too and I still got same error 500. Note:My timeout currently is 120000ms and all files are given full permissions.