图片无法上传

时间:2019-12-30 18:43:34

标签: php html mysql file-upload

我已将此提交给我的编码。但是图片没有上传到我的文件夹中。刚刚在数据库中提交了文件名。

all_kbproduct_list.php

<form class="form-signin user" method="post" enctype="multipart/form-data" action="all_kbproduct_list.php">
<label for="inputname" style="font-size:20px;color:#000">Product Image</label><br/>
<input type="file" name="kbpimg" class="form-control-file" id="exampleFormControlFile1">
<button class="btn btn-primary btn-user btn-block" name="khucrabazar" type="submit">Submit</button>

function.php

if (isset($_POST['khucrabazar'])) {
        khucrabazar();
    }

    // khucrabazar
    function khucrabazar(){
        global $db, $errors;

        // receive all input values from the form
        $kbpimg = $_FILES['kbpimg']['name'];
        $target = "img/kbproduct/".basename($kbpimg);
        $kbpname = e($_POST['kbpname']);
        $kbpdetails = e($_POST['kbpdetails']);
        $kbpseotitle = e($_POST['kbpseotitle']);
        $kbpseodetail = e($_POST['kbpseodetail']);
        $kbpseokeyword = e($_POST['kbpseokeyword']);
        $kbpprice = e($_POST['kbpprice']);
        $kbpcode = e($_POST['kbpcode']);
        $category = e($_POST['category']);
        $date = date('Y-m-d H:i:sa');

        // register user if there are no errors in the form
        if (count($errors) == 0) {

                $sql = "INSERT INTO khucrabazar (kbpimg, kbpname, kbpdetails, kbpseotitle, kbpseodetail, kbpseokeyword, kbpprice, kbpcode, category, date)
                          VALUES('$kbpimg', '$kbpname', '$kbpdetails', '$kbpseotitle', '$kbpseodetail', '$kbpseokeyword', '$kbpprice', '$kbpcode', '$category', '$date')";
                mysqli_query($db, $sql);


        if (move_uploaded_file($_FILES['kbpimg']['tmp_name'], $target)) {
            echo "Image Submited Successfully.";
        }else{
            echo "Failed to upload Image.";
            }

        }

    }

请解决此问题。我很麻烦:'(

0 个答案:

没有答案