function Upload($file, $path, $codificar = null) { $uploadDir = INTERNAL_ROOT_PORTAL . '/' . $path; //Verificar se tem que renomear o arquivo if ($codificar == null) { $name = $file['name']; $uploadFile = $uploadDir . $name; $extension = pathinfo($file['name'], PATHINFO_EXTENSION); } else { $name = sha1(date("d-m-Y H:i:s")); $uploadFile = $uploadDir . $name; $extension = pathinfo($file['name'], PATHINFO_EXTENSION); $uploadFile = $uploadFile . '.' . $extension; $name .= '.' . $extension; } //Fazer o Upload do arquivo if (move_uploaded_file($file['tmp_name'], $uploadFile)) { $tipos = array("jpg", 'jpeg', 'png', 'gif'); if (in_array($extension, $tipos)) { $resizeObj = new Thumb($uploadFile); $resizeObj->resizeImage(64, 64); $resizeObj->saveImage($uploadDir . '/thumb/' . $name, 100); } $data['error'] = 0; $data['name'] = $name; } else { $data['error'] = 1; $data['name'] = NULL; } return $data; }