Skip to content

Commit

Permalink
Added Error Message When File Fails to Write (prasathmani#399)
Browse files Browse the repository at this point in the history
Added error checking and message for when file fails to write on the server side.  Before this change if a write failed on the server side it would still present the user with a misleading "Saved Successfully" Message.
  • Loading branch information
zachlankton committed Jul 20, 2020
1 parent e427011 commit de7479f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tinyfilemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,12 @@ function session_error_handling_function($code, $msg, $file, $line) {
$writedata = $_POST['content'];
$fd = fopen($file_path, "w");
@fwrite($fd, $writedata);
$write_results = @fwrite($fd, $writedata);
fclose($fd);
if ($write_results === false){
header("HTTP/1.1 500 Internal Server Error");
die("Could Not Write File! - Check Permissions / Ownership");
}
die(true);
}

Expand Down Expand Up @@ -3743,7 +3748,8 @@ function edit_save(e, t) {
contentType: "multipart/form-data-encoded; charset=utf-8",
//dataType: "json",
success: function(mes){toast("Saved Successfully"); window.onbeforeunload = function() {return}},
failure: function(mes) {toast("Error: try again");}
failure: function(mes) {toast("Error: try again");},
error: function(mes) {toast(`<p style="background-color:red">${mes.responseText}</p>`);}
});

}
Expand Down

0 comments on commit de7479f

Please sign in to comment.