From 09e2b9a1076a287b9e74e52997abad7f8194e4a9 Mon Sep 17 00:00:00 2001 From: Agent Smith <67276662+AgentSmith0@users.noreply.github.com> Date: Fri, 6 Aug 2021 04:13:22 +0200 Subject: [PATCH] Fix saving of empty files (#612) When you have a file without content, for example when you cleared you were unable to save it because of an incorrect if-statement. This is the fix for that problem. --- tinyfilemanager.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index fb79563..714524c 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -3804,8 +3804,8 @@ $isStickyNavBar = $sticky_navbar ? 'navbar-fixed' : 'navbar-normal'; //Save file function edit_save(e, t) { var n = "ace" == t ? editor.getSession().getValue() : document.getElementById("normal-editor").value; - if (n) { - if(true){ + if (typeof n !== 'undefined' && n !== null) { + if (true) { var data = {ajax: true, content: n, type: 'save'}; $.ajax({ @@ -3819,9 +3819,7 @@ $isStickyNavBar = $sticky_navbar ? 'navbar-fixed' : 'navbar-normal'; failure: function(mes) {toast("Error: try again");}, error: function(mes) {toast(`

${mes.responseText}

`);} }); - - } - else{ + } else { var a = document.createElement("form"); a.setAttribute("method", "POST"), a.setAttribute("action", ""); var o = document.createElement("textarea");