43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
class Random_saran extends MY_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
function upload()
|
|
{
|
|
//upload ke s3
|
|
global $_FILES;
|
|
$name = $_FILES["file"]["name"];
|
|
$type = $_FILES["file"]["type"];
|
|
$xid = $_POST["xid"];
|
|
$tmp_name = $_FILES["file"]["tmp_name"];
|
|
$a_ext = explode("\\", $type);
|
|
$ext = "ogg";
|
|
if (count($a_ext) > 1) {
|
|
$ext = $a_ext[1];
|
|
}
|
|
$fname = "$xid.$ext";
|
|
$this->load->library("Sas_s3");
|
|
$resp = $this->sas_s3->upload("audio-sample", "$xid.{$ext}", $type, file_get_contents($tmp_name));
|
|
if ($resp['@metadata']['statusCode'] == 200) {
|
|
echo json_encode(["status" => "OK", "result" => "file $name of $type ulded to s3 $xid.ogg "]);
|
|
};
|
|
}
|
|
function index()
|
|
{
|
|
$sql = "select concat(Mcu_ResumeKesimpulan, ' Untuk itu disarankan ',
|
|
Mcu_ResumeSaran) text
|
|
from
|
|
mcu_resume
|
|
where length(Mcu_ResumeSaran) > 20
|
|
and length(Mcu_ResumeSaran) > 20
|
|
order by rand()
|
|
limit 0, 1 ";
|
|
$qry = $this->db->query($sql);
|
|
$rows = $qry->result_array();
|
|
echo json_encode(["status" => "OK", "data" => $rows]);
|
|
}
|
|
}
|