merubah text menjadi gambar menggunakan codeigniter

kira kira apa yang salah ya atau kurang dari coding di bawah?????? hasil gambar engga tersimpan


$params = json_decode(file_get_contents('php://input'), TRUE);
if ($params['teks'] == "" ) {
$respStatus = 400;
$jsonAr = array(
"_meta" => array('status' => 'ERROR','count' => 1),
"result" => array('errorCode' => 400,'userMessage' => 'Teks can\'t empty')
);
$resp = $jsonAr;
json_output($respStatus,$resp);
} else {
header('Content-type: image/jpeg');
$im = imagecreatetruecolor(400, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = $params['teks'];
// Replace path by your own font path
$font = 'arial.ttf';
// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
$config['upload_path'] = "./gambar_teks/".$im;
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$this->load->library('upload', $config);
$im = $params['gambar_teks'];
$resp = $this->m_teks->create_data($params);
if ($resp['errorCode']  == 200) {
$stat = "SUCCESS";
}else{
$stat = "ERROR";
}
$count = array($resp);
$jsonAr = array(
"_meta" => array('status' => $stat,'count' => count($count)),
"result" => $resp
);
json_output($resp['errorCode'],$jsonAr);
}
avatar abdulrojakUG
@abdulrojakUG

59 Kontribusi 0 Poin

Diperbarui 6 tahun yang lalu

1 Jawaban:

Error nya apaan? Dan itu permission untuk foldernya udh dcheck?

avatar mukhsinsin
@mukhsinsin

11 Kontribusi 2 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban