i am working on a project that detects facial expressions in python.but i have to provide image to this code through php.The following php code saves image in directory.how can i call the following code in html button.
<?php
function fun(){
$img = $_POST['image'];
$folderPath = "C:/xampp/htdocs/";
$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 = '1'. '.jpeg';
$file = $folderPath . $fileName;
file_put_contents($file, $image_base64);
print_r($fileName);
$command = escapeshellcmd("python C:/xampp/htdocs/generate_graph.py");
$output = shell_exec($command);
}
?>
See Question&Answers more detail:os