How to upload file in Dropzone tutorial example

PHP Upload file using Dropzone. Dropzone is light weight and easy to use library

let’s have create demo for file upload using dropzone.

Create file index.php

<!DOCTYPE html>
  <title>PHP Dropzone File Upload Example Tutorial</title>

  <link href="" rel="stylesheet">
  <script src=""></script>
  <link href="" rel="stylesheet">
  <script src=""></script>
<div class="container">
  <div class="row">
    <div class="col-md-12">
      <h2>PHP Dropzone File Upload on Button Click Example</h2>
      <form action="upload.php" enctype="multipart/form-data" class="dropzone" id="image-upload">
      <button id="uploadFile">Upload Files</button>
<script type="text/javascript">
    Dropzone.autoDiscover = false;
    var myDropzone = new Dropzone(".dropzone", { 
       autoProcessQueue: false,
       maxFilesize: 1,
	   addRemoveLinks: true,
       acceptedFiles: ".jpeg,.jpg,.png,.gif"

autoProcessQueue you can set false or true, true means image upload instantly without click on submit button.
maxFilesize is set 1 which allow image to upload 1MB increase or descease as per your needs.
addRemoveLinks is set true or false based on needs. Remove appear on image when it true so when you will require to delete image from server set it true

acceptedFiles checks the file’s mime type or extension when you upload the file. We define .jpeg,.jpg,.png,.gif. You will change it based on your needs.

Now create File Upload Code for PHP to accept files and save to server

Read Also : PHP file upload in database with Error Handling


$uploadDir = 'uploads';
if (!empty($_FILES)) {
	$tmpFile = $_FILES['file']['tmp_name'];
	$filename = $uploadDir.'/'.time().'-'. $_FILES['file']['name'];
PHP Dropzone File Upload output

Leave a Reply