Welcome folks today in this tutorial we will e talking about drag ad drop file uploads using dropzone js library in php full example.
In this video i have explained you step by step the process which is required to make the file upload using this library.
1. Download and Include
- Download Dropzone.js library from here.
- Include
dropzone.css
anddropzone.js
files in your page.
you can also include from the cdn also.
1 2 |
<link href='dropzone.css' type='text/css' rel='stylesheet'> <script src='dropzone.js' type='text/javascript'></script> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<!doctype html> <html> <head> <link href="style.css" rel="stylesheet" type="text/css"> <link href="dropzone.css" rel="stylesheet" type="text/css"> <script src="dropzone.js" type="text/javascript"></script> </head> <body > <div class="container" > <div class='content'> <form action="upload.php" class="dropzone" id="dropzonewidget"> </form> </div> </div> </body> </html> |
PHP Code
1 2 3 4 5 6 7 |
<?php $target_dir = "upload/"; $target_file = $target_dir . basename($_FILES["file"]["name"]); if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_dir.$_FILES['file']['name'])) { $status = 1; } |