我的文件和信息不会上传(mysqli& PHP)

时间:2015-05-19 16:06:55

标签: javascript php jquery html5 css3

您好我已经构建了一个上传器,可以上传一些数据和图像。

该表单在网页上显示没有错误,但不会上传。

这是一个屏幕截图,也附有代码。

http://simplicity-designs.tk/images/Screenshot%20%28104%29.png

  <?php
    include("includes/connect.php");

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

     $title = $_POST['title'];
     $date = date('d-m-y'); 
     $author = $_POST['author'];    
     $image = $_FILES['image']['name']; 
     $keywords = $_POST['keywords'];    
     $content = $_POST['content'];
     $image_tmp = $_FILES['image']['tmp_name'];

     if($title == '' or $author == '' or $keywords == '' or $content == ''){
        echo "
            <script>
                alert('PLEASE CHECK YOUR FORM IS COMPLETE')
            </script>";
        exit();  

        move_uploaded_file($image_tmp, "../images/$image");

    }else{


        $sqli = "INSERT INTO posts (title, date, author, image, keywords, content) VALUES ('$title', ''$date , '$author', '$image', '$keywords', '$content')";
    }};
?>





<!doctype html>
<html>
    <head>
        <title>Inserting Data</title>
        <meta charset="utf-8">

    </head>

    <body>

        <form action="insert_data.php" id="InsertDataForm" method="post" enctype="multipart/form-data">
            <table width="600" align="center" border="10">
                <tr>
                    <td align="center" bgcolor="#CC6600" colspan="6"><h1>Insert New Data Here</h1></td>
                </tr>


                <tr>
                    <td align="right">Data Title</td>
                    <td><input style="width:300px;" type="text" name="title"/></td>
                </tr>


                <tr>
                    <td align="right">Data Author</td>
                    <td><input style="width:300px;" type="text" name="author"/></td>
                </tr>


                <tr>
                    <td align="right">Data Keywords</td>
                    <td><input style="width:300px;" type="text" name="keywords"/></td>
                </tr>


                <tr>
                    <td align="right">Data Image</td>
                    <td><input style="width:300px; height:50px;" type="file" name="image"/></td>
                </tr>


                <tr>
                    <td align="right">Data Content</td>
                    <td><textarea style="max-width:300px; max-height:300px;" name="content" cols="48" rows="20"></textarea></td>
                </tr>

                <tr>
                    <td align="center" colspan="6"><input style="width:200px; height:50px;
                    margin:5px 0px;" type="submit" name="submit" value="Insert Data Now"/></td>
                </tr>

            </table>
        </form>


    </body>
</html>

连接脚本

<?php
    $connect = mysqli_connect("localhost","########","####","#######");
?> 

没有不好的帖子只是帮助PLZ我不想要拼写纠正或否定我想要帮助。

提前致意并表示感谢

1 个答案:

答案 0 :(得分:1)

首先请确保在php.ini中取消注释file_uploads。

file_uploads=On       instead of         ;file_uploads=On

您的INSERT也有错误。在$ date值。

你有

 ''$date     instead of      '$date'

更改为...

 $sqli = "INSERT INTO posts (title, date, author, image, keywords, content) VALUES ('$title', '$date' , '$author', '$image', '$keywords', '$content')";