+ <?php
+ }
+
+ if ($settings['allow_external_refs']) {
+ ?>
+ <a href="https://github.com/muchweb/simple-php-upload" target="_blank"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
+ <?php
+ } else {
+ ?>
+ <a href="https://github.com/muchweb/simple-php-upload" target="_blank">Fork me on GitHub</a>
+ <?php
+ }
+ ?>
+ <script type="text/javascript">
+ <!--
+ // Init some variales to shorten code
+ var target_form = document.getElementById('simpleupload-form');
+ var target_ul = document.getElementById('simpleupload-ul');
+ var target_input = document.getElementById('simpleupload-input');
+ var settings_listfiles = <?=($settings['listfiles'] ? 'true' : 'false')?>;
+
+ /**
+ * Initializes the upload form
+ */
+ function init () {
+ // Register drag-over event listener
+ target_form.addEventListener('dragover', function (event) {
+ event.preventDefault();
+ }, false);
+
+ // ... and the drop event listener
+ target_form.addEventListener('drop', handleFiles, false);
+
+ // Register onchange-event function
+ target_input.onchange = function () {
+ addFileLi('Uploading...', '');
+ target_form.submit();
+ };
+ }
+
+ /**
+ * Adds given file in a new li-tag to target_ul list
+ *
+ * @param name Name of the file
+ * @param info Some more informations
+ */
+ function addFileLi (name, info) {
+ if (settings_listfiles == false) {
+ return;
+ }
+
+ target_form.style.display = 'none';
+
+ var new_li = document.createElement('li');
+ new_li.className = 'uploading';
+
+ var new_a = document.createElement('a');
+ new_a.innerHTML = name;
+ new_li.appendChild(new_a);
+
+ var new_span = document.createElement('span');
+ new_span.innerHTML = info;
+ new_a.appendChild(new_span);
+
+ target_ul.insertBefore(new_li, target_ul.firstChild);
+ }
+
+ /**
+ * Handles given event for file upload
+ *
+ * @param event Event to handle file upload for
+ */
+ function handleFiles (event) {
+ event.preventDefault();
+
+ var files = event.dataTransfer.files;
+
+ var form = new FormData();
+
+ for (var i = 0; i < files.length; i++) {
+ form.append('file[]', files[i]);
+ addFileLi(files[i].name, files[i].size + ' bytes');
+ }
+
+ var xhr = new XMLHttpRequest();
+ xhr.onload = function() {
+ window.location.reload();
+ };
+
+ xhr.open('post', '<?php echo $data['scriptname']; ?>', true);
+ xhr.send(form);
+ }
+
+ // Initialize upload form
+ init();
+
+ //-->
+ </script>