上载的文件未在php中的指定文件夹中移动

时间:2019-05-21 06:04:03

标签: php file

我有一个名为abstract_submission的php文件,为了处理该文件中的表单,我创建了Submitted_abstract php文件。但是move_uploaded文件功能不起作用。对于文件,我创建了一个名为submissions的文件夹。有人对此有解决方案吗?

我尝试在if语句中上下移动插入查询,但这不起作用。

<?php

    $con = mysqli_connect("localhost",MYSQL_USER,MYSQL_PASSWORD,"svavpo_phicon");


    ini_set('display_errors', 1);
    ini_set('display_startup-errors', 1);
    error_reporting(E_ALL);

    $edit_state = false;


    if(isset($_POST['sybmitabs']))
    {

        $name = $_POST['name'];
        $email = $_POST['email'];
        $category = $_POST['category'];
        $subm_category = $_POST['subm_category'];
        $main_category = $_POST['main_category'];
        $title = $_POST['title'];
        $author = $_POST['author'];
        $body = $_POST['body'];
        $reference = $_POST['reference'];


        $file = $_FILES['file']['name'];
        $target = "submissions/".basename($_FILES['file']['name']);

        $sql = "INSERT INTO `sub_abstract`(`name`, `email`, `category`, `subm_category`, `main_category`, `title`, `author`, `body`, `reference`, `file`) VALUES ('$name','$email','$category','$subm_category','$main_category','$title','$author','$body','$reference','$file')";


        $result=mysqli_query($con,$sql);


        if(move_uploaded_file($_FILES['file']['tmp_name'], $target))
        {
            echo "errro in updating db";
        }
        else
        {

            echo ("<script LANGUAGE='JavaScript'>
        window.alert('Abstract Submitted Succesfully !');
        window.location.href='../abstract_submission.php';
        </script>");
        }



    }

?>

0 个答案:

没有答案