Version 1.4

This commit is contained in:
sud0nick 2018-01-12 21:47:31 -05:00
parent c7e3b0cbc0
commit e6af6358a3
4 changed files with 22 additions and 10 deletions

View File

@ -37,24 +37,27 @@ if (!empty($_FILES)) {
$response = [];
foreach ($_FILES as $file) {
$tempPath = $file[ 'tmp_name' ];
$name = $file['name'];
$name = pathinfo($file['name'], PATHINFO_FILENAME);
$type = pathinfo($file['name'], PATHINFO_EXTENSION);
// Ensure the upload directory exists
if (!file_exists(__PAYLOADS__)) {
if (!mkdir(__PAYLOADS__, 0755, true)) {
$response[$name] = "Failed";
$response[$name]['success'] = "Failed";
$response[$name]['message'] = "Failed to create payloads directory";
echo json_encode($response);
die();
}
}
$uploadPath = __PAYLOADS__ . $name;
$uploadPath = __PAYLOADS__ . $name . "." . $type;
$res = move_uploaded_file($tempPath, $uploadPath);
if ($res) {
$response[$name] = "Success";
$response[$name]['success'] = "Success";
} else {
$response[$name] = "Failed";
$response[$name]['success'] = "Failed";
$response[$name]['message'] = "Failed to upload payload '" . $name . "." . $type . "'";
}
}
echo json_encode($response);

View File

@ -0,0 +1,4 @@
January 12, 2018
<br /><br />
- Updated upload functionality to include better responses if uploads fail<br />

View File

@ -684,13 +684,18 @@ registerController('CursedScreechController', ['$api', '$scope', '$sce', '$inter
transformRequest: angular.identity,
headers: {'Content-Type': undefined}
}).then(function(response) {
for (var key in response) {
if (response.hasOwnProperty(key)) {
if (response.key == "Failed") {
alert("Failed to upload " + key);
var errors = {};
for (var key in response.data) {
if (response.data[key].success == "Failed") {
var msg = response.data[key].message + '\n';
if (!errors.hasOwnProperty(msg)) {
errors[msg] = true;
}
}
}
if (Object.keys(errors).length > 0) {
alert(Object.keys(errors).join(''));
}
$scope.selectedFiles = [];
$scope.getPayloads();
$scope.uploading = false;

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "CursedScreech",
"version": "1.3"
"version": "1.4"
}