Não consigo pegar o código do cliente.
Pessoal, estou com um problema.
Preciso pegar o código do cliente, pra salvar uma foto tirada na webcam em outra tabela, nessa tabela tem as colunas id, código_cliente, image. Consigo salvar o caminho da foto normal, só que precisa salvar o código do cliente, quando eu coloco o código manualmente salva, mas quando eu uso o .$_GET['codigo']. não puxa o código do cliente, não estou conseguindo ver o que há de errado.
Segue o código abaixo.
<?php
include "../lib/config.inc.php";
include "../lib/func.inc.php";
include "../lib/classes.inc.php";
require_once( dirname( __FILE__ ) . '/connectionClass.php' );
require_once '../lang/'.$idioma.'.php';
class webcamClass extends connectionClass{
private $imageFolder="webcamImage/";
//This function will create a new name for every image captured using the current data and time.
private function getNameWithPath(){
$name = $this->imageFolder.date('YmdHis').".jpg";
return $name;
}
public function showImage(){
$file = file_put_contents( $this->getNameWithPath(), file_get_contents('php://input') );
if(!$file){
return "ERROR: Failed to write data to ".$this->getNameWithPath().", check permissions\n";
}
else
{
$this->saveImageToDatabase($this->getNameWithPath());
return $this->getNameWithPath();
}
}
public function changeImagetoBase64($image){
$path = $image;
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
return $base64;
}
public function saveImageToDatabase($imageurl){
$image=$imageurl;
// $image= $this->changeImagetoBase64($image);
if($image){
$query="Insert into snapshot (codigo_paciente, Image) values('".$_GET['codigo']."', '$image')";
//$query="Insert into snapshot (codigo_paciente, Image) values('codigo', '$image')";
$result= $this->query($query);
if($result){
return "Image saved to database";
}
else{
return "Image not saved to database";
}
}
}
}Discussão (1)
Carregando comentários...