Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require ('load/conecta.php');
- require ('load/functions.php');
- if (isset($_FILES['foto'])){
- if (!isset($_FILES['foto']['name']) || empty($_FILES['foto']['name'])){
- $erro[] = "Informa uma foto";
- }
- if (ereg("[][><}{)(:;,!?*%&#@]", $_FILES['foto']['name'])) {
- $erro[] = "Arquivo contem caracteres invalidos.";
- }
- if ($_FILES['foto']['size'] > 1000000) {
- $erro[] = "Fotos com no maximo 1 MB.";
- }
- if (substr($_FILES['foto']['type'],-3) != "jpg" && substr($_FILES['foto']['type'],-3) != "JPG" && substr($_FILES['foto']['type'],-3) != "gif" && substr($_FILES['foto']['type'],-3) != "GIF"){
- $erro[] = "Tipo de arquivo invalido.";
- }
- if (!is_file($_FILES['foto']['tmp_name'])) {
- $erro[] = "Seleciona um arquivo";
- }
- if (is_dir($_FILES['foto']['name'])) {
- $erro[] = "Selecione um aqruivo para ser enviado.";
- }
- if (!isset($erro)) {
- if (!copy($_FILES['foto']['tmp_name'], "./newgremio/images/".$_FILES['foto']['name'])) {
- $erro[] = "Erro ao enviar foto.";
- }
- }
- $fotos = "/newgremio/images/".$_FILES['foto']['name'];
- }
- $titulo = addslashes(trim(strip_tags($_POST[titulo])));
- $chamada = addslashes(trim(strip_tags($_POST[chamada])));
- $noticia = addslashes(trim(strip_tags($_POST[noticia])));
- $autor = addslashes(trim(strip_tags($_POST[autor])));
- $hora = addslashes(trim(strip_tags($_POST[hora])));
- $data = addslashes(trim(strip_tags($_POST[data])));
- $destaque = addslashes(trim(strip_tags($_POST[destaque])));
- $sql = "insert into noticias (titulo, chamada, noticia, autor, hora, data, destaque, foto) values ('$titulo', '$chamada', '$noticia', '$autor', '$hora', '$data', '$destaque','$fotos')";
- $resultado = mysql_query($sql);
- echo "Noticia cadastrada com sucesso";
- ?>
Add Comment
Please, Sign In to add comment