Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <?php
  2.  
  3. if(is_file($_FILES['arquivo']['tmp_name'])){
  4.  
  5.  $foto = $_FILES['arquivo']['name'];
  6.  
  7.  if(!eregi("^image\/(jpeg|png|jpg)$", $_FILES['arquivo']['type'])){
  8.  
  9.   echo "
  10.  <META HTTP-EQUIV=REFRESH CONTENT='0; URL=index.html'>
  11.  <script type=\"text/javascript\">
  12.  alert(\"Formato inválido\");
  13.  </script>
  14.  ";
  15.  
  16.  }else{
  17.  
  18.   if(file_exists("uploads/$foto")){
  19.    $a = 1;
  20.    while(file_exists("uploads/[$a]$foto")){
  21.     $a++;
  22.    }
  23.    
  24.    $foto = "[".$a."]".$foto;
  25.    
  26.   }
  27.  
  28.   if(!move_uploaded_file($_FILES['arquivo']['tmp_name'], "uploads/".$foto)){
  29.    
  30.    echo "
  31.  <META HTTP-EQUIV=REFRESH CONTENT='0; URL=index.html'>
  32.  <script type=\"text/javascript\">
  33.  alert(\"Erro ao enviar o arquivo.\");
  34.  </script>
  35.  ";
  36.    
  37.   }
  38.  
  39.  }
  40.  
  41.   header("Location: index.html");
  42.  
  43. }else{
  44.  header("Location: index.html");
  45. }
  46.  
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement