Guest User

Untitled

a guest
Jun 13th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. <?php
  2.  
  3. require ('load/conecta.php');
  4. require ('load/functions.php');
  5.  
  6. if (isset($_FILES['foto'])){
  7.  
  8. if (!isset($_FILES['foto']['name']) || empty($_FILES['foto']['name'])){
  9. $erro[] = "Informa uma foto";
  10. }
  11. if (ereg("[][><}{)(:;,!?*%&#@]", $_FILES['foto']['name'])) {
  12. $erro[] = "Arquivo contem caracteres invalidos.";
  13. }
  14. if ($_FILES['foto']['size'] > 1000000) {
  15. $erro[] = "Fotos com no maximo 1 MB.";
  16. }
  17. 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"){
  18. $erro[] = "Tipo de arquivo invalido.";
  19. }
  20. if (!is_file($_FILES['foto']['tmp_name'])) {
  21. $erro[] = "Seleciona um arquivo";
  22. }
  23. if (is_dir($_FILES['foto']['name'])) {
  24. $erro[] = "Selecione um aqruivo para ser enviado.";
  25. }
  26. if (!isset($erro)) {
  27. if (!copy($_FILES['foto']['tmp_name'], "./newgremio/images/".$_FILES['foto']['name'])) {
  28. $erro[] = "Erro ao enviar foto.";
  29. }
  30. }
  31. $fotos = "/newgremio/images/".$_FILES['foto']['name'];
  32. }
  33.  
  34.  
  35.  
  36. $titulo = addslashes(trim(strip_tags($_POST[titulo])));
  37. $chamada = addslashes(trim(strip_tags($_POST[chamada])));
  38. $noticia = addslashes(trim(strip_tags($_POST[noticia])));
  39. $autor = addslashes(trim(strip_tags($_POST[autor])));
  40. $hora = addslashes(trim(strip_tags($_POST[hora])));
  41. $data = addslashes(trim(strip_tags($_POST[data])));
  42. $destaque = addslashes(trim(strip_tags($_POST[destaque])));
  43.  
  44. $sql = "insert into noticias (titulo, chamada, noticia, autor, hora, data, destaque, foto) values ('$titulo', '$chamada', '$noticia', '$autor', '$hora', '$data', '$destaque','$fotos')";
  45. $resultado = mysql_query($sql);
  46.  
  47. echo "Noticia cadastrada com sucesso";
  48.  
  49. ?>
Add Comment
Please, Sign In to add comment