Esempio n. 1
0
function uploadImages($images, $regId)
{
    $Upload = new Upload();
    $regImage = new NcRegImage();
    if (!empty($images)) {
        foreach ($images as $img) {
            if (!empty($img->FILE)) {
                $Title = Check::Name(substr($img->FILE->name, 0, strrpos($img->FILE->name, '.')));
                $FileName = $Title . strrchr($img->FILE->name, '.');
                $Upload->Image((array) $img->FILE);
                unlink($img->FILE->tmp_name);
                $regImage->setImage_name($FileName);
                $regImage->setImage_url($Upload->getResult());
                $regImage->setImage_date(date('Y-m-d H:i:s'));
                $regImage->setReg_id($regId);
                $regImage->Execute()->insert();
            }
        }
    }
}
<?php

$Read = new NcRegImage();
switch ($method) {
    case "GET":
        //retorna todos os itens
        $Read->Execute()->findAll();
        Check::JsonReturn($Read->Execute()->getResult(), 'Nenhuma origem cadastrado!', '204');
        break;
    case "POST":
        //update não implementado
        echo json_encode($request);
        break;
    case "DELETE":
        //deleta não implementado
        echo json_encode($delete);
        break;
    default:
        break;
}