Exemplo n.º 1
0
function uploadFiles($files, $regId)
{
    if (!empty($files)) {
        $Upload = new Upload();
        $regFile = new NcRegFile();
        foreach ($files as $file) {
            if (!empty($file->FILE)) {
                $Title = Check::Name(substr($file->FILE->name, 0, strrpos($file->FILE->name, '.')));
                $FileName = $Title . strrchr($file->FILE->name, '.');
                $Upload->File((array) $file->FILE, null, null, 50);
                $regFile->setFile_name($FileName);
                $regFile->setFile_url($Upload->getResult());
                $regFile->setFile_date(date('Y-m-d H:i:s'));
                $regFile->setReg_id($regId);
                $regFile->Execute()->insert();
            }
        }
    }
}
<?php

$Read = new NcRegFile();
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;
}