Guest User

Untitled

a guest
Apr 24th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. <?php
  2. $end = '</div></div></body></html>';
  3. echo '<html><head><meta http-equiv="content-type" charset="utf-8" /><link href="styles.css" rel="stylesheet" /><title>Upload completed</title></head><body><div id="first"><h1>Upload completed</h1><div id="second">';
  4. if (isset($_FILES['arquivo']) && !empty($_FILES['arquivo']))
  5.     {
  6.     $err = $_FILES['arquivo']['error'];
  7.     $name = $_FILES['arquivo']['name'];
  8.     $type = $_FILES['arquivo']['type'];
  9.     echo 'Upando "'.htmlentities($name).'"...<br />';
  10.     if ($err > 0)
  11.         {
  12.         echo 'Erro ao upar!<br />Código do erro: '.$err.$end;
  13.         }
  14.     elseif ($type == 'image/jpeg' || $type == 'image/pjpeg' || $type == 'image/gif' || $type == 'image/png' || $type == 'image/bmp')
  15.         {
  16.         $rand = md5(rand(0,99).time());
  17.         $exp = explode('.',$name);
  18.         $ext = end($exp);
  19.         move_uploaded_file($_FILES['arquivo']['tmp_name'],'upload/'.$rand.'.'.$ext);
  20.         echo 'O arquivo "'.htmlentities($name).'" foi upado com sucesso!<br /><a href="upload/'.$rand.'.'.$ext.'" target="_blank">Veja o arquivo clicando aqui.</a>'.$end;
  21.         }
  22.     else
  23.         {
  24.         echo 'O arquivo "'.htmlentities($name).'" não é de um tipo de imagem válido!'.$end;
  25.         }
  26.     }
  27. else
  28.     {
  29.     echo 'Selecione um arquivo do seu computador!<br /><a href="index.html">Clique aqui para voltar</a>'.$end;
  30.     }
  31. ?>
Add Comment
Please, Sign In to add comment