First, you don't need to wrap the <input type="file">
with a div around it and then with javscript trigger the .click()
event for that input file if you click the div, make a <label>
for this input file and style it, thus you can trigger the click event with HTML only without the need for javascript:
<label for="openFile" id="browseFile"></label>
<input id="openFile" name="img" type="file">
Updated: Then, as in this JS Fiddle the problem is that you need to return false;
for the ondragover
and ondrop
events
var browseFile = document.getElementById('browseFile');
browseFile.ondragover = function () {
return false;
};
browseFile.ondrop = function (event) {
event.preventDefault && event.preventDefault();
var files = event.dataTransfer.files;
console.log(files);
return false;
};
** Note that the above works for multiple files as well.
Resource: http://html5doctor.com/drag-and-drop-to-server/
So I am using bootstrap and have collapse panels I wish to implement plus and minus icons. I have currently done it using the code below found on stackoverflow, i can't remember the link so will edit ...
So I am using bootstrap and have collapse panels I wish to implement plus and minus icons. I have currently done it using the code below found on stackoverflow, i can't remember the link so will edit ...
I am trying to import svg image from file into next.js component. In assets folder I have google.svg(icon): <svg className="svgIcon-use" width="25" height="37" viewBox="0 0 25 25"> <g ...
I am trying to import svg image from file into next.js component. In assets folder I have google.svg(icon): <svg className="svgIcon-use" width="25" height="37" viewBox="0 0 25 25"> <g ...
I have a video gallery with thumbnails. when I click on a thumbnail a video shows up. how can I stop/reset video that's playing when I click on another thumbnail? here is the code I have function ...
I have a video gallery with thumbnails. when I click on a thumbnail a video shows up. how can I stop/reset video that's playing when I click on another thumbnail? here is the code I have function ...
I am trying to print array element to console using for each loop in javascript. But I am printing something which I am not able to figure out what! let arr=["1,2,3","iosajah","undefined"]; for(...
I am trying to print array element to console using for each loop in javascript. But I am printing something which I am not able to figure out what! let arr=["1,2,3","iosajah","undefined"]; for(...