I want to make drag and drop upload. User drops the files on div, and when he clicks on upload button, they are sent to server. javascript unfortunatelly does not know what variable fd is. How I can pass that variable to DragAndDropUpload() function.. Not sure if that is the real problem..
Im wondering whether to show you my website or not :D
here is my code(only important things , I removed the other things to make code look smaller)
Should I pass fd to function as an argument? o.O or what
$(document).ready(function(){
var fd;
var drag_area = $("#drag_and_drop_div");
drag_area.on('drop', function(e){
e.preventDefault();
$("#nahraj_button").show();
$("#upload_button").attr('onclick','DragAndDropUpload()');
var files = e.originalEvent.dataTransfer.files;
fd = new FormData();
fd.append('file[]',files[0]);
});
});
function DragAndDropUpload(){
var request = new XMLHttpRequest();
request.open('POST', 'uploader.php');
request.send(fd);
}
EDIT: Console shows this: Uncaught Reference error: fd is not defined