After moving one of our websites from Linux with Apache to Windows with IIS (8.5) running PHP 5.6 via FastCGI, we've run into the problem that file_get_contents('php://input')
returns an empty string for PUT requests.
I've created the following test:
<?php
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) &&
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
die(file_get_contents('php://input'));
}
?>
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
</head>
<body>
<h2>POST:</h2>
<div id="post"></div>
<h2>PUT:</h2>
<div id="put"></div>
<script>
$.ajax({
url: '?',
data: 'Working',
type: 'POST'
}).then(function(response) {
$('#post').html(response || 'Not working');
});
$.ajax({
url: '?',
data: 'Working',
type: 'PUT'
}).then(function(response) {
$('#put').html(response || 'Not working');
});
</script>
</body>
</html>
Which results in:
POST:
Working
PUT:
Not working
What could be causing this?