Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="usuario.php" method="POST" enctype="multipart/form-data">
- <label for="imagem">Imagem:</label>
- <input type="file" name="imagem"/>
- <br/>
- <input type="submit" value="Enviar"/>
- </form>
- <?php
- $imagem = $_FILES["imagem"];
- $host = "localhost";
- $username = "root";
- $password = "";
- $db = "diligencia";
- if($imagem != NULL) {
- $nomeFinal = time().'.jpg';
- if (move_uploaded_file($imagem['tmp_name'], $nomeFinal)) {
- $tamanhoImg = filesize($nomeFinal);
- $mysqlImg = addslashes(fread(fopen($nomeFinal, "r"), $tamanhoImg));
- mysql_connect($host,$username,$password) or die("Impossível Conectar");
- @mysql_select_db($db) or die("Impossível Conectar");
- mysql_query("INSERT INTO arquivos (arquivo) VALUES ('$mysqlImg')") or die("O sistema não foi capaz de executar a query");
- unlink($nomeFinal);
- header("location:exibir.php");
- }
- }
- else {
- echo"Você não realizou o upload de forma satisfatória.";
- }
- ?>
Add Comment
Please, Sign In to add comment