JavaScript / AJAX file upload

# add this code snipset to your homepage and customize path to upload.php
<img src="http://cdn1.iconfinder.com/data/icons/metro-uinvert-dock/256/MS_Office_Upload_Center.png" id="dropzone" title="Upload">
<script src="http://raw.githubusercontent.com/enyo/dropzone/master/downloads/dropzone.js"></script>
<script type="text/javascript">
var myDropzone = new Dropzone("#dropzone", {url: "upload.php"});
myDropzone.on("success", function(file) {
    location.reload();
});
</script>
 
# create upload.php on your webserver
<?php
$DIR = "upload";
if(!empty($_FILES)) {
    // move file to upload directory
    move_uploaded_file($_FILES['file']['tmp_name'], $DIR . "/" . $_FILES['file']['name']);
}
?>
 
# OPTIONAL: create .htaccess to alow php file execution in a specific directory
<FilesMatch "\.(php)$">
SetHandler application/x-httpd-php
</FilesMatch>
 
# Links
http://www.dropzonejs.com/
http://www.heise.de/ct/inhalt/2012/16/172/ - c't  Uploader 2.0, Mehrere Dateien parallel auf die eigene Website hochladen
ftp://ftp.heise.de/pub/ct/listings/1216-172.zip - Download c't  Uploader 2.0