Implementing Multiple File Drag and Drop Upload using HTML5 and Jquery.
💻 coding

Implementing Multiple File Drag and Drop Upload using HTML5 and Jquery.

1 min read 246 words
1 min read
ShareWhatsAppPost on X
  • 1The article explains how to implement a multiple file drag and drop upload feature using HTML5, jQuery, and PHP.
  • 2This system supports modern browsers and utilizes AJAX for file uploads with the Form Data and File Reader APIs.
  • 3To set up, include the jQuery library and multiupload.js, and configure the necessary parameters in the JavaScript code.

AI-generated summary · May not capture all nuances

Key Insight
AskGif

"The article explains how to implement a multiple file drag and drop upload feature using HTML5, jQuery, and PHP."

Implementing Multiple File Drag and Drop Upload using HTML5 and Jquery.

Are you looking for Drag and Drop multiple file upload using HTML5. Just take a look at this post, I had implemented this system by using jquery and PHP that uploads multiple files into server. This script helps you to enrich your web applications upload system. It works with all modern browsers try the live demo and drop files.

Multiple File Drag and Drop Upload this will work in modern browsers like Chrome, Firefox, and Safari, File uploads happening through ajax

for this, I implemented with Form Data and File Reader javascript API.

Requirements

- Jquery (tested with 1.7+)

- HTML 5

How to use

Just include Jquery library and multiupload.js files available in download script.

Javascript Code

All config parameters are required. If you want to allow other files formats, add in valid files variable.

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/multiupload.js"></script>
<script type="text/javascript">
var config = {
// Valid file formats
support : "image/jpg,image/png,image/bmp,image/jpeg,image/gif", 
form: "demoFiler", // Form ID
dragArea: "dragAndDropFiles", // Upload Area ID
uploadUrl: "upload.php" // Server side file url
}
//Initiate file uploader.
$(document).ready(function()
{
initMultiUploader(config);
});
</script>

upload.php

Simple PHP code uploading files from client mechanic to server location uploads folder.

if($_SERVER['REQUEST_METHOD'] == "POST")
{
if(move_uploaded_file($_FILES['file']['tmp_name'], "uploads/".$_FILES['file']['name']))
{
echo($_POST['index']); // to validate 
}
exit;
}

HTML5 Code

HTML5 drag and drop form.

<div id="dragAndDropFiles" class="uploadArea">
<h1>Drop Images Here</h1>
</div>
<form name="demoFiler" id="demoFiler" enctype="multipart/form-data">
<input type="file" name="multiUpload" id="multiUpload" multiple />
<input type="submit" name="submitHandler" id="submitHandler" value="Upload" />
</form>
<div class="progressBar">
<div class="status"></div>
</div>

Enjoyed this article?

Share it with someone who'd find it useful.

ShareWhatsAppPost on X

AskGif

Published on 29 August 2019 · 1 min read · 246 words

Part of AskGif Blog · coding

You might also like