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 8405367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:50:13+00:00 2026-06-09T22:50:13+00:00

The following code is from a page that is dedicated exclusively for uploading images

  • 0

The following code is from a page that is dedicated exclusively for uploading images on imgur.com. This is a model from the net and you can drag and drop images from your pc whit no problems. My question is: What code i need to add so that i can drag and drop images from another browser?

    <!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<title>Upload</title>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>.

    <style>
    body {text-align: center; padding-top: 100px;}
    div { border: 10px solid black; text-align: center; line-height: 100px; width: 200px; margin: auto; font-size: 40px; display: inline-block;}
    #link, p , div {display: none}
    div {display: inline-block;}
    .uploading div {display: none}
    .uploaded div {display: none}
    .uploading p {display: inline}
    .uploaded #link {display: inline}
    </style>

<script>
window.ondragover = function(e) {e.preventDefault()}
window.ondrop = function(e) {e.preventDefault(); upload(e.dataTransfer.files[0]); }
function upload(file) {

    if (!file || !file.type.match(/image.*/)) return;

    document.body.className = "uploading";

    var fd = new FormData();
    fd.append("image", file);
    fd.append("key", "myapicode");
    var xhr = new XMLHttpRequest();
    xhr.open("POST", "http://api.imgur.com/2/upload.json");
    xhr.onload = function() {

    document.querySelector("#link").href = JSON.parse(xhr.responseText).upload.links.imgur_page;

    var test = JSON.parse(xhr.responseText).upload.links.imgur_page;

    var dataString = 'content=' + test + '&page=something';
    $.ajax({
    type: "POST",
    url: "upload.img.php",
    data: dataString,
    cache: false,
    success: function(html){
    }
    });
    document.body.className = "uploaded";
    }
    xhr.send(fd);
}
</script>

</head>
<body>

<div>DROP!<button onclick="document.querySelector('input').click()">Or click</button></div>
<input style="visibility:collapse;width:0px;" type="file" onchange="upload(this.files[0])">
<p>Uploading...</p>
<a id="link">Its online!!!</a>

</body>
</html>
  • 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-09T22:50:14+00:00Added an answer on June 9, 2026 at 10:50 pm

    Not all browsers support this, but Firefox will let you drag an image out of the browser to another browser or your computer, while Chrome does not allow you to drag an image out of the browser.

    This page has a so called dropzone, open it in Chrome and open an image in Firefox, and you can drag the image straight from Firefox to Chrome, however it does not seem to work the other way around.

    The script is well commented and should give you some ideas, and the drag and drop stuff is basically set up like :

    var dropzone;  
        dropzone = document.getElementById("dropzone");  
        dropzone.addEventListener("dragenter", dragin, false);
        dropzone.addEventListener("dragleave", dragout, false);
        dropzone.addEventListener("dragover", stopPropagation, false);
        dropzone.addEventListener("drop", drop, false);  
    

    Where dragin, dragout, drop etc. are functions called on those events that you will find in the script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In C#, the following code (from this page) can be used to lazily instantiate
The following code is from a details page that receives a querystring from another
Hi I found the following code from this page JQuery UI DatePicker using 2
I took the following code from the examples page on Asio class tcp_connection :
I'm using the following code to get response from a requested page using php
i write the following code to access page JQueryPage.aspx and get data from it
I have some JS on my site that should prevent the following code from
I have the following code but when I submit the from the page redirects.
I am working on an ASP.NET page that we, in code impersonate the requesting
I have a Classic ASP page that contains the following code to attempt a

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.