diff --git a/files/ajax/upload.php b/files/ajax/upload.php
index b3facf967237205edb53b937c979b94f3074bcc8..79b6c0b284ccdc8b2dfdbab49f0793b63b20e001 100644
--- a/files/ajax/upload.php
+++ b/files/ajax/upload.php
@@ -27,6 +27,8 @@ and $_SESSION['username'] and strpos($dir,'..') === false){
 	}
 }
 
-echo json_encode(array( "status" => "error"));
+$error = $_FILES['file']['error'];
+
+echo json_encode(array( 'status' => 'error', 'data' => array('error' => $error)));
 
 ?>
diff --git a/files/js/files.js b/files/js/files.js
index ba08e254349a13c11ef10ef745e8896761f073e6..9eeeb7f6bfd23d15aef95b6a59da8fa3f3a3c0f1 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -53,7 +53,7 @@ function uploadFinished() {
 	result = $('#file_upload_target').contents().text();
 	result = eval("(" + result + ");");
 	if(result.status == "error") {
-		alert('An error occcured, upload failed.');
+		alert('An error occcured, upload failed.\nError code: ' + result.data.error);
 	} else {
 		location.href = 'index.php?dir=' + $('#dir').val();
 	}