Skip to content

Commit

Permalink
Add JSON Parse Error Handling in Upload Script (prasathmani#1196)
Browse files Browse the repository at this point in the history
* Add JSON Parse Error Handling in Upload Script

* Update tinyfilemanager.php

* Update tinyfilemanager.php
  • Loading branch information
FannieMC authored May 31, 2024
1 parent 843e240 commit a4d96e0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tinyfilemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1398,10 +1398,14 @@ function getUploadExt() {
toast('Error: Server Timeout');
});
}).on("success", function (res) {
let _response = JSON.parse(res.xhr.response);
try {
let _response = JSON.parse(res.xhr.response);

if(_response.status == "error") {
toast(_response.info);
if(_response.status == "error") {
toast(_response.info);
}
} catch (e) {
toast("Error: Invalid JSON response");
}
}).on("error", function(file, response) {
toast(response);
Expand Down

0 comments on commit a4d96e0

Please sign in to comment.