public static function Type($_formName = 'file') { $_type = $_FILES[$_formName]['type']; switch ($_type) { case 'image/gif': if (self::$a == NULL) { self::$a = new imgUpload($_formName); } break; case 'image/pjpeg': if (self::$a == NULL) { self::$a = new imgUpload($_formName); } break; case 'image/x-png': if (self::$a == NULL) { self::$a = new imgUpload($_formName); } break; default: self::$a = false; } return self::$a; }
<?php include "models/function.php"; if (isset($_POST["go"])) { $objImg = new UploadImg(); $name_img = $objImg->upload($_FILES, $_POST["photo_now"]); $objAttr = new AttrValue(); $data_attr = $objAttr->conbine($_POST["attr"], $_POST["val"]); if (isset($_POST["related"]) and $_POST["related"]) { $related = array_slice($_POST["related"], 0, 4); $data_related = serialize($related); } else { $data_related = ""; } require_once "classes/Product.php"; $obj = new Product(); if ($_POST["go"] == "save") { $fff = $obj->insert($obj->insertSql(), trimStr($_POST["section"]), trimStr($_POST["name"]), trimStr($_POST["nomer"]), trimStr($_POST["brand"]), trimStr($_POST["viscous"]), trimStr($_POST["type"]), trimStr($_POST["volume"]), trimStr($_POST["kol"]), trimStr($_POST["price"]), trimStr($_POST["text"]), $data_related, $data_attr, trimStr($_POST["title"]), trimStr($_POST["description"]), trimStr($_POST["keywords"]), $name_img, trimStr($_POST["img_title"]), trimStr($_POST["img_alt"])); header("Location: production.php?id=" . $_POST["section"]); } else { $obj->update($obj->updateSql(), trimStr($_POST["section"]), trimStr($_POST["name"]), trimStr($_POST["nomer"]), trimStr($_POST["brand"]), trimStr($_POST["viscous"]), trimStr($_POST["type"]), trimStr($_POST["volume"]), trimStr($_POST["kol"]), trimStr($_POST["price"]), trimStr($_POST["text"]), $data_related, $data_attr, trimStr($_POST["title"]), trimStr($_POST["description"]), trimStr($_POST["keywords"]), $name_img, trimStr($_POST["img_title"]), trimStr($_POST["img_alt"]), $_POST['go']); header("Location: production.php?id=" . $_POST["section"]); } } if (isset($_GET["delete"])) { $delete = new Delete(); $delete->del($_GET["title"], $_GET["delete"]); header("Location: production.php?id=" . $_GET["delete"]); } require_once "classes/Catalog.php"; $section = new Catalog();
<div class="panel-body row"> <div class="col-sm-6"> <?php $form_ops = new parseCSV(); $form_ops->delimiter = ';'; $uf = new UploadImg(); if (isset($_POST['form-button'])) { // TODO: chamar classe CSV, retornando um array com todas as matrículas $csv = new parseCSV(); $csv->delimiter = ';'; $csv->parse('dados.csv'); $csvData = $csv->data; $matriculas = []; foreach ($csvData as $data) { $matriculas[] = $data['matricula']; } if (!in_array($_POST['form-matricula'], $matriculas)) { $uf->setFileImg($_FILES['form-imagem']); if ($uf->checkImgExtension()) { echo '<div class="alert alert-success" role="alert"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span> Imagem enviada!</div>'; $form_ops->save('dados.csv', array(array($_POST['form-matricula'], $_POST['form-email'], $_POST['form-name'], $_POST['form-curso'], $_POST['form-turma'])), true); $uf->upload_img($_FILES['form-imagem'], $_POST['form-curso'], $_POST['form-turma'], $_POST['form-matricula'], $uf->getImgExtension()); } else { echo '<div class="alert alert-danger" role="alert"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> A imagem não está no formato correto! Por favor, faça upload de uma imagem em PNG, JPG ou JPEG.</div>'; } } else { echo '<div class="alert alert-danger" role="alert"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> Já existe um cadastro com essa matrícula :(</div>'; } } ?> <form class="form-horizontal" role="form" id="formulario" method="post" action="index.php" enctype="multipart/form-data">