diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php
index d4ef8dc116bc95831aa399c978ab2db2754b36e2..f8d62cb577353fb47da16a11d891a9e2ea8141e2 100644
--- a/lib/exe/ajax.php
+++ b/lib/exe/ajax.php
@@ -281,7 +281,8 @@ function ajax_mediaupload(){
         }
         $result = array('error' => $msg['msg'], 'ns' => $NS);
     }
-    echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
+    $json = new JSON;
+    echo htmlspecialchars($json->encode($result), ENT_NOQUOTES);
 }
 
 function dir_delete($path) {