Dropzone php mysql Example with Demo

Today, We want to share with you Dropzone php mysql Example with Demo.In this post we will show you Dropzone Multiple Image upload validation, hear for Laravel Dropzonejs Multiple File Upload using jQuery we will give you demo and example for implement.In this post, we will learn about DropzoneJS send additional data Multiple File Upload with an example.

Simple Dropzone php mysql Example with Demo

There are the Following The simple About Simple Dropzone php mysql Example with Demo Full Information With Example and source code.

As I will cover this Post with live Working example to develop filestack – DropZone Allowed File Extensions Tutorials, so the How to display existing files on server in Dropzone js using PHP for this example is following below.

Read Also:  how to get last inserted id in laravel 6?

Create Index.php File:

<!DOCTYPE html>
<html>
<head>
    <title>jQuery Ajax Dropzone display uploaded files on server PHP - Pakainfo.com</title>
    <script src="jquery/3.3.1/jquery.min.js"></script>
    <link href='dropzone/5.4.0/dropzone.css' type='text/css' rel='stylesheet'>
    <script src='dropzone/5.4.0/dropzone.js' type='text/javascript'></script>
    <style type="text/css">
      .dz-preview .dz-image img{
        width: 100% !important;
        height: 100% !important;
        object-fit: cover;
      }
    </style>
</head>
<body>
  
<div class="container pakainfo" >
  <h1>jQuery Ajax Dropzone display uploaded files on server in PHP <BR/> Pakainfo.com</h1>
  <div class='content'>
    <form action="do_multipleFilesUplodad.php" class="dropzone" >  
    </form> 
  </div> 
</div>
  
<script type="text/javascript">
  Dropzone.autoDiscover = false;
  $(".dropzone").dropzone({
    init: function() { 
      liveDropzone = this;
      $.ajax({
        url: 'do_multipleFilesUplodad.php',
        type: 'post',
        data: {request: 'get_request'},
        dataType: 'json',
        success: function(response){
  
          $.each(response, function(key,value) {
            var mockFile = { name: value.name, size: value.size};
  
            liveDropzone.emit("addedfile", mockFile);
            liveDropzone.emit("thumbnail", mockFile, value.path);
            liveDropzone.emit("complete", mockFile);
  
          });
  
        }
      });
    }
  });
</script>
  
</body>
</html>

Create Index.php File:

<?php
  
/* Upload PHP To directory Moves*/
$finalDirdata = "upload/";
  
$destination_path = "upload";
if(isset($_POST['request'])){
  $request = $_POST['request'];
}
  
/* Upload file */
if($destination_path == "upload"){
  $msg = "";
  if (move_uploaded_file($_FILES["file"]["tmp_name"], $finalDirdata.$_FILES['file']['name'])) {
    $msg = "Successfully uploaded";
  }else{ 
    $msg = "Error while uploading";
  }
  echo $msg;
  exit;
}
  
/* Read files from */
if($request == 'get_request'){
  $allFiles = [];
  
  $is_dir = $finalDirdata;
  if (is_dir($is_dir)){
    if ($dh = opendir($is_dir)){
      while (($file = readdir($dh)) !== false){
        if($file != '' && $file != '.' && $file != '..'){
          $file_path = $finalDirdata.$file;
          if(!is_dir($file_path)){
             $size = filesize($file_path);
             $allFiles[] = ['name'=>$file, 'size'=>$size, 'path'=>$file_path];
          }
        }
      }
      closedir($dh);
    }
  }
  
  echo json_encode($allFiles);
  exit;
}

Angular 6 CRUD Operations Application Tutorials

Read :

Read Also:  Renaming file while uploading Laravel

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Simple Dropzone php mysql Example with Demo.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.