PHP脚本/ apache2服务器中的PUT方法

时间:2017-10-30 14:09:53

标签: php apache2

我正在为初学者寻找明确的答案如何在linux下配置apache2服务器,以便能够通过PUT方法发送/重放文件,同时如何在PHP中编写脚本以获取捕获数据并将其保存到spec中的可能性。夹。我已经阅读了一些在本论坛上给出的答案,但没有一个给我100%的可能性来理解如何成功实现我的目标

我有192.168.1.10下的客户端,它通过HTTP PUT方法发送event.json文件 服务器位于192.168.1.50 linux PC(运行apache2服务器)

也许有不同的方式来实现我的目标?

你好,所以我写了一些代码(基本的)

/ var / www / html #index.html

<input type="file" name="avatar" size="50" />

jej.php

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

我做了cmd:curl -X PUT -d arg = val -d arg2 = val2 127.0.0.1:80

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

和其他: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 127.0.0.1 Port 80</address>
</body></html>

问题是=&gt; 1. PUT方法是否正确实施?我必须在apache中启用一些东西吗? 2.我的php.sh是否被正确编写为读取JSON数据(将从客户端发送到服务器)以及所有JSON数据是否可以在服务器页面上进行访问?

0 个答案:

没有答案