Image upload code does not send gif to folder

Asked

Viewed 24 times

0

I was trying to send images to the database, and the best way was to save them in a directory and send only the name to MYSQL, only when I send a gif, it n goes to the directory but usually goes to mysql...

<?php 
require ('connect.php');
mysql_connect("$host", "$usuario", "$senha");
mysql_select_db("$bd");
if ($_POST['enviar']) {
    $nome = $_POST['nome'];
    $usuario = $_POST['usuario'];
    $senha = $_POST['senha'];
    $foto = $_FILES['foto']['tmp_name'];
    $extensao = strtolower(pathinfo($_FILES['foto']['name'], PATHINFO_EXTENSION));
    $nome_imagem = uniqid();
    $caminho_imagem = "imagens";
    $search = mysql_query("SELECT * FROM usuarios WHERE usuario='$usuario'");
    $checar = mysql_num_rows($search);
    //if ($checar == 0) {
    mysql_query("INSERT INTO usuarios(nome,usuario,senha,foto) values('".$nome."','".$usuario."','".$senha."','".$nome_imagem.".".$extensao."')");
    move_uploaded_file ($foto, $caminho_imagem."/".$nome_imagem.".".$extensao);
    //}

}

This is the registration code...

  • then, you must have permission problem in the folder. put an IF to check if you uploaded and then insert

  • 1

    if(move_uploaded_file ($photo, $path_image."/".$filename.".".$extension)) { mysql_query("INSERT INTO users(name,user,password,photo) values('".$name."','".$user."','".$password."','".$filename."."$extension."')"; }

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.