上传文件,并将文件名插入数据库

It's me again. I have a problem in inserting the name of the uploaded file on the database. I've successfully uploaded the file and the file has been moved to the dir that I want, can anyone help me to figure it out what's wrong in my code? Also, I've tried putting some echo on it and I got "not success", and make the database value nullable. here's my code.

  <?php
        session_start();
        include "../../3rdparty/engine.php";
        ini_set('display_errors', 1);
        ini_set('display_startup_errors', 1);
        error_reporting(E_ALL);
        if ($_SESSION['daya_user'] != '') {

            if ($_FILES['dokumen']['name'] != "") {
                //print_r($_POST);
                    $path = $_FILES['dokumen']['name'];
                    $ext = pathinfo($path, PATHINFO_EXTENSION);
                    $nama_file = 'SO'.'-'.date("Ymd").'.'.$ext;
                    @copy($_FILES['dokumen']['tmp_name'], '../../dokumen_atk/'.$nama_file);

            mysqli_query($con,"insert into tbl_atk (name_file) values ('$nama_file')");
            header("location:../../index.php?mod=atk&submod=so_upload");
    }
}
//header("location:../../index.php?mod=atk&submod=so_upload");

?>

do it like this.

change this

$insert = $db->query("insert into tbl_atk_upload (name_file) values ('$nama_file')", 0

to

mysqli_query($con,"insert into tbl_atk (name_file) values ('$nama_file')");
header('location:success.php'); //redirect to your success page

Note: you need to include your db connection and call it whenever when you use query. Like the given example variable $con above and don't enclose your query to if/eslse condition cause it's a bad habit.