Join WhatsApp ChannelJoin Now

How To Dropzone Add Download Button In Php

Hi,

Today, i we will show you how to dropzone add download button in php. This article will give you simple example of how to dropzone add download button in php. you will learn how to dropzone add download button in php.

If you wish to feature transfer uploaded get into dropzone then we are going to show you the way to feature transfer button on uploaded file with Ajax request. we are going to add transfer link and it’ll transfer file from server in dropzone.js.dropzone give success operate and that we can append a tag with uploaded file path. here we are going to use php with dropzone to transfer file from server.

So let’s follow few step to create example of how to dropzone add download button in php.

How To Dropzone Add Download Button In Php

Index.php

<!DOCTYPE html>
<html>
<head>
  <title>How To Dropzone Add Download Button In Php</title>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css" />
  <link href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.0.1/min/dropzone.min.css" rel="stylesheet">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.2.0/min/dropzone.min.js"></script>
</head>
<body>
   
<div class="container">
  <div class="row">
    <div class="col-md-12">
      <h2>How To Dropzone Add Download Button In Php </h2>
      <form action="upload.php" enctype="multipart/form-data" class="dropzone" id="image-upload">
        <input type="hidden" name="request" value="add">
        <div>
          <h3>Upload Multiple Image By Click On Box</h3>
        </div>
      </form>
    </div>
  </div>
</div>
   
<script type="text/javascript">
  
    Dropzone.autoDiscover = false;
  
    var myDropzone = new Dropzone(".dropzone", { 
       maxFilesize: 10,
       acceptedFiles: ".jpeg,.jpg,.png,.gif",
       success: function (file, response) {
        if(response != 0){
           var anchorEl = document.createElement('a');
           anchorEl.setAttribute('href',response);
           anchorEl.setAttribute('target','_blank');
           anchorEl.innerHTML = "<br>Download File";
           file.previewTemplate.appendChild(anchorEl);
        }
       }
    });
   
</script>
  
</body>
</html>

upload.php

<?php
  
$uploadDir = 'upload';
  
$tmpFile = $_FILES['file']['tmp_name'];
$filename = $uploadDir.'/'.$_FILES['file']['name'];
move_uploaded_file($tmpFile,$filename);
  
echo $filename;
  
?>

I hope it will assist you…

Recommended Posts