var fileobj; function upload_file(e) { e.preventDefault(); fileobj = e.dataTransfer.files[0]; ajax_file_upload(fileobj); } function file_explorer() { document.getElementById('uploadfile').click(); document.getElementById('uploadfile').onchange = function() { fileobj = document.getElementById('uploadfile').files[0]; ajax_file_upload(fileobj); }; } function copytoclipboard() { var elm = document.getElementById("divresponse"); var selection = window.getSelection(); var range = document.createRange(); range.selectNodeContents(elm); selection.removeAllRanges(); selection.addRange(range); document.execCommand("Copy"); } function ajax_file_upload(file_obj) { var divresponse = document.getElementById('divresponse'); divresponse.innerHTML = "Uploading file..." ; $.ajax( { type: 'PUT', url: 'index.php', contentType: false, processData: false, data: file_obj, success:function(response) {; divresponse.innerHTML = response ; document.getElementById('copytoclipboard').style.visibility = "visible"; } }); }