move_uploaded_file does not move files

2

I have a form (in php, I wanted to ask if it works without problem?) to insert images (the path of them) and when I enter the inserted in the database but the image does not move to the folder I'm requesting.

Here is the code I downloaded:

<?php

    include '../conn.php';
    mysqli_set_charset($con,"utf8");

    $id = $_GET['id'];

    $imagem    = $_FILES['imagem']['tmp_name'];
    $img_name = $_FILES['imagem']['name'];

    $dir      = "../imagens/viaturas/";
    $path     = $dir.$img_name;

    move_uploaded_file( $imagem, $path );    


    $sql = "INSERT INTO carros_img(id_fk, img) VALUES ($id, '$img_name')";

    if(mysqli_query($con, $sql)){
    echo "<script>
             document.location.href = '../admin/carros.php?id=$id';
     </script>";
    }
    else{
        echo "<script>
            alert('Imagem não enviada');
            document.location.href = '../admin/quem.php?id=$id';
        </script>";  
     }  
?>

The path of the image appears in bd but the image does not move from folder. Any problems with the code?

    
asked by anonymous 06.10.2016 / 10:37

1 answer

0

Permission 755 in the folder where the files will be moved. If no error is presented the paths appear to be correct.

    
14.10.2016 / 16:00