HDTuto.com

PHP Dropzone Allow only One File to Upload Example



If you need to see example of how to allow only one file to upload in dropzone.js. step by step explain dropzone js allow only one image. you will learn dropzone js allow only one file. We will use dropzone allow only one file upload. Let's get started with dropzone js accept only one file.

If you have to allow only one file upload in dropzone js then i will help you how to add option to accept only one file in dropzone js. you can easily make solution with jquery, php, laravel and other framework too.

Dropzone JS provide "maxFiles" option there you can set max allow number of file. so you can make 1 as maxFiles in your js code. so let's see bellow code and you can make done your solution.

Solution:

Dropzone.options.imageUpload = {

maxFilesize:10,

maxFiles: 1,

acceptedFiles: ".jpeg,.jpg,.png,.gif"

};

Example:

<!DOCTYPE html>

<html>

<head>

<title>How to Allow Only One File to Upload in Dropzone?</title>

<script src="http://demo.itsolutionstuff.com/plugin/jquery.js"></script>

<link rel="stylesheet" href="http://demo.itsolutionstuff.com/plugin/bootstrap-3.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 Allow Only One File to Upload in Dropzone?</h2>

<form action="upload.php" enctype="multipart/form-data" class="dropzone" id="image-upload">

<div>

<h3>Upload Multiple Image By Click On Box</h3>

</div>

</form>

<button id="uploadFile">Upload Files</button>

</div>

</div>

</div>

<script type="text/javascript">

Dropzone.autoDiscover = false;

Dropzone.options.imageUpload = {

maxFilesize:10,

maxFiles: 1,

acceptedFiles: ".jpeg,.jpg,.png,.gif"

};

</script>

</body>

</html>

i also added more tutorial about step by step file uploading with dropzone using php and laravel as bellow:

PHP Dropzone File Uploading Example

Laravel Dropzone File Uploading Example

Angular Dropzone File Uploading Example

PHP Dropzone File Upload on Button Click Example

I hope it can help you...




July 17, 2020 | Category : PHP



Blog Search