Мое приложение должно взять значение снимка изображения и загрузить его в определенное место.
За пределами CakePHP этот код работает нормально, но, помещенный в контроллер, я получаю сообщение об ошибке:
Несоответствие токена CSRF.
Торт \ Http \ Exception \ InvalidCsrfTokenException
HTML:
<input type=button value="Take Snapshot"
onClick="take_snapshot()">
<input type="hidden" name="image" class="image-tag">
PHP:
if ($this->request->is(['post','put',])) {
$img = $_POST['image'];
$folderPath = "C:/upload/";
$image_parts = explode(";base64,", $img);
$image_type_aux = explode("image/", $image_parts[0]);
$image_type = $image_type_aux[1];
$image_base64 = base64_decode($image_parts[1]);
$fileName = uniqid() . '.jpg';
$file = $folderPath . $fileName;
file_put_contents($file, $image_base64);
print_r($fileName);
}