Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $end = '</div></div></body></html>';
- 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">';
- if (isset($_FILES['arquivo']) && !empty($_FILES['arquivo']))
- {
- $err = $_FILES['arquivo']['error'];
- $name = $_FILES['arquivo']['name'];
- $type = $_FILES['arquivo']['type'];
- echo 'Upando "'.htmlentities($name).'"...<br />';
- if ($err > 0)
- {
- echo 'Erro ao upar!<br />Código do erro: '.$err.$end;
- }
- elseif ($type == 'image/jpeg' || $type == 'image/pjpeg' || $type == 'image/gif' || $type == 'image/png' || $type == 'image/bmp')
- {
- $rand = md5(rand(0,99).time());
- $exp = explode('.',$name);
- $ext = end($exp);
- move_uploaded_file($_FILES['arquivo']['tmp_name'],'upload/'.$rand.'.'.$ext);
- echo 'O arquivo "'.htmlentities($name).'" foi upado com sucesso!<br /><a href="upload/'.$rand.'.'.$ext.'" target="_blank">Veja o arquivo clicando aqui.</a>'.$end;
- }
- else
- {
- echo 'O arquivo "'.htmlentities($name).'" não é de um tipo de imagem válido!'.$end;
- }
- }
- else
- {
- echo 'Selecione um arquivo do seu computador!<br /><a href="index.html">Clique aqui para voltar</a>'.$end;
- }
- ?>
Add Comment
Please, Sign In to add comment