不显示之前通过dropzone上传的图像

时间:2018-11-29 18:52:09

标签: php jquery html css dropzone

我使用一些互联网资源创建了拖放文件上传系统.dropzone.js文件中使用了该文件。当将更新数据库和文件的图像拖放到特定文件夹时,但是当我尝试显示上传的图像时在上载文件区域之前显示为空。

这是源代码

index.php

  <!DOCTYPE html>
       <html lang="en-US">
       <head>

      <meta charset="utf-8">
       </head>
      <link rel="stylesheet" href="css/dropzone.css">
     <script type="text/javascript" src="js/dropzone.js"></script>
      <body>
       <div class="container">

        <div class="upload-div">
            <form action="upload.php" class="dropzone"></form>
        </div>
    </div>

    <!-- Display uploaded File -->
    <div class="uploaded-files">
        <?php
        //Included the database configuration file
        require 'dbConfig.php';

        //Get Files from the database
        $query = $db->query("SELECT * FROM files ORDER BY id DESC");

        if($query->num_rows >0)
        {

            while($row = $query->fetch_assoc()) {
                $filePath = 'uploads/'.$row['file_name'];
                $fileMimeType = mime_content_type($filePath);
                </script>";
                ?>
                <embed src="<?php echo $filePath; ?>" type="<?php echo $fileMimeType; ?>" width="350" height="280"/>

                <?php
            }
            }else{
                echo '<p>No File(s) Found...</p>';
            }

        ?>
    </div>

 </body>
 </html>

upload.php

  <?php 
     if(!empty($_FILES)){

        require 'dbConfig.php';

        //File Path Configuration
        $targetDir = "uploads/";
        $fileName = $_FILES['file']['name'];
        $targetFilePath = $targetDir.$fileName;

        //Upload file to server
        if(move_uploaded_file($_FILES['file']['tmp_name'],$targetFilePath )){

        //Insert file information in the database

          $insert = $db->query("INSERT INTO files(file_name,upload_on) VALUES ('".$fileName."' , NOW())");

        }
     }

     ?>

表结构 enter image description here

请帮助我解决这个问题。谢谢!

0 个答案:

没有答案