Im looking for clear answer for beginners how to configure apache2 sever under linux to have capabilities to send/ recive files via PUT method and in the meantime how to write a script in PHP to have possibilities to capture data and save them into spec. folder. I have read some off answers which have been given on this forum but none of them gave me 100% possibilite to understand how to successfully reach my objectives
I have client under 192.168.1.10 which send event.json file via HTTP PUT method Server is at 192.168.1.50 linux PC (apache2 server running under)
Maybe there is different way to achieve my goal ?
Hello so I have written some code (basic)
/var/www/html# index.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>JSON_read</title>
</head>
<body>
<form method="put"
action="http://192.168.1.50/jej.php">
</form>
</body>
</html>
jej.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>JSON_read results</title>
</head>
<body>
<p>
<?php
$value = @file_get_contents('http://192.168.1.50/events.json');
var_dump(json_decode($value));
var_dump(json_decode($value, true));
?>
<p>
</body>
</html>
and I did cmd : curl -X PUT -d arg=val -d arg2=val2 127.0.0.1:80
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The requested method PUT is not allowed for the URL /index.html.</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at 127.0.0.1 Port 80</address>
</body></html>
and other : curl -X PUT -d arg=val -d arg2=val2 192.168.1.50:80
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The requested method PUT is not allowed for the URL /index.html.</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at 192.168.1.50 Port 80</address>
</body></html>
Question is => 1. whether PUT method is correctly implemented ? Do I have to enable something in apache ? 2. whether my php.sh was correctly written to read JSON data (which will be send from client to the server) and if all JSON data would be visibile on server page ?