CodeIgniter_3.1.11 – $this->input->post ist null
Posted: 07 Jan 2025, 14:17
Bei der Verwendung von $this->input->post('policy') ist ein Problem aufgetreten. Manchmal (1 bei einer unregelmäßigen Anzahl von Versuchen) ist es null, was zu Fehlern im weiteren Code führt. Wenn ich es mit php://input überprüfe, kann ich gültiges JSON sehen.
Beispiel:
Vue-Code:
Hier ist mein htaccess:
Was kann dieses Problem verursachen?
Beispiel:
Code: Select all
public function createPolicy()
{
$rawPostData = file_get_contents('php://input');
$inputPost = $this->input->post('policy');
$this->applicationLogger->debug('DEBUG', 'Raw POST data: ', $rawPostData);
// it log valid json
$this->applicationLogger->debug('DEBUG', 'POST policy: ',json_encode($inputPost));
// it log null
}
Code: Select all
let data = {
policy: this.policy
};
axios
.post('Controller/createPolicy', data, {
headers: {
'Content-Type': 'application/json'
}
})
Code: Select all
RedirectMatch 404 /\.git
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/server-status
RewriteRule ^(.*)$ index.php/$1 [L]