Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8532961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:50:21+00:00 2026-06-11T09:50:21+00:00

i want to know how to do the drag and drop image upload.the thing

  • 0

i want to know how to do the drag and drop image upload.the thing i don’t understand is that how to let server know when a user drops an image inside a certain div or to body for uploading?is that supported in all common browsers ie,ff,chrome,safari. thank you 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:50:23+00:00Added an answer on June 11, 2026 at 9:50 am

    I can tell you haven’t done much research.

    Short answer is, no. There is no method that is supported in all major browsers that will detect when a user drops an image inside the client window.

    Also, as Rajat Saxena pointed out in the comments, you’d have to inform the server of a file drop by sending an ajax request on the drop event.


    HTML5

    Here’s drag and drop from desktop to browser using HTML5 and javascript

    <div id="drop_zone">Drop files here</div>
    <output id="list"></output>
    
    <script>
      function handleFileSelect(evt) {
        evt.stopPropagation();
        evt.preventDefault();
    
        var files = evt.dataTransfer.files; // FileList object.
    
        // files is a FileList of File objects. List some properties.
        var output = [];
        for (var i = 0, f; f = files[i]; i++) {
          output.push('<li><strong>', escape(f.name), '</strong> (', f.type || 'n/a', ') - ',
                      f.size, ' bytes, last modified: ',
                      f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a',
                      '</li>');
        }
        document.getElementById('list').innerHTML = '<ul>' + output.join('') + '</ul>';
      }
    
      function handleDragOver(evt) {
        evt.stopPropagation();
        evt.preventDefault();
        evt.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
      }
    
      // Setup the dnd listeners.
      var dropZone = document.getElementById('drop_zone');
      dropZone.addEventListener('dragover', handleDragOver, false);
      dropZone.addEventListener('drop', handleFileSelect, false);
    </script>
    

    JQuery

    Here’s a drag and drop from desktop to browser using JQuery (Firefox and Chrome)

    function ignoreDrag(e) {
      e.originalEvent.stopPropagation();
      e.originalEvent.preventDefault();
    }
    
    $('#target')
        .bind('dragenter', ignoreDrag)
        .bind('dragover', ignoreDrag);
        .bind('drop', drop);
    
    function drop(e) {
      ignoreDrag(e);
      var dt = e.originalEvent.dataTransfer;
      var files = dt.files;
    
      if(dt.files.length > 0){
        var file = dt.files[0];
        alert(file.name);
      }
    }
    

    Other related links to plugins (not tested) and questions

    • Is there a good jQuery Drag-and-drop file upload plugin?
    • file upload via drag and drop
    • jQuery Drag Image From Desktop Plugin
    • Drag-n-Drop from Desktop jQuery Plugin
    • Javascript for Drag file From desktop and drop into webpage
    • jQuery File Upload Demo
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that when a drag/drop operation is completed, upon receiving a MouseUp or
I know that I can use the JQueryUI Drag and Drop with some of
I want to make a few boxes that I can drag and drop into
I just want to know how can i drag and drop a line which
I want to know if there is any kind of report on maven that
So, I'm writing an AS3 program that tiles floor tiles. I want the user
I find drag-and-drop difficult (you know, keeping the mouse button depressed while moving), and
I know how to do drag and drop in C# when it comes to
I want to make a WPF Grid in which users can drag and drop
I drag a draggable object to a droppable object. I want to know if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.