conf = new MConfigLoader(); $MIOLO->conf->LoadConf(); $urlContext = $MIOLO->conf->getConf('home.url') . '/' . $MIOLO->conf->getConf('options.dispatch') ."?module=selectiveProcess&action=main:process:selectiveProcess"; $MIOLO->context = new MContext($urlContext, 0, false); $MIOLO->context->isFile = true; require_once '../classes/support.inc'; $MIOLO->init(); if (!$MIOLO->auth->CheckLogin(false)) { exit('Não autorizado!'); } if(isset($_FILES['upload'])) { try { $types = [ 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.oasis.opendocument.text', 'application/zip', 'application/vnd.rar', 'image/gif', 'image/jpeg', 'image/png' ]; $verificaMimeType = in_array($_FILES['upload']['type'], $types); if (!$verificaMimeType) { throw new Exception('Esse tipo de arquivo não é permitido! Apenas PDF, DOC, DOCX, OTD, ZIP, RAR, GIF, JPEG e PNG'); } $filen = $_FILES['upload']['tmp_name']; $con_files = $_SERVER['DOCUMENT_ROOT'] . "/miolo20/html/files/" . $_FILES['upload']['name']; mkdir(dirname($con_files), 0777, true); move_uploaded_file($filen, $con_files); $getProxySchema = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; $url = $getProxySchema . str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['SERVER_NAME'], $con_files); echo json_encode(["url" => $url]); } catch (Exception $e) { echo json_encode(["error" => ["message" => "Falha ao anexar imagem: " . $e->getMessage()]]); } } ?>