|
|
|
|
@ -40,8 +40,27 @@ function rename_upload(string $uploadName, string $fileName, false|string $rndFi |
|
|
|
|
if ($rndFile === false) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
$success = rename($uploadName, $GLOBALS['uploadDir'] . 'orignal_' . $rndFile . '_' . $fileName); |
|
|
|
|
return ($success) ? $GLOBALS['uploadDir'] . 'orignal_' . $rndFile . $fileName . '_': false; |
|
|
|
|
|
|
|
|
|
list($originalWidth, $originalHeight, $imageType) = getimagesize($uploadName); |
|
|
|
|
if ($originalWidth == 0 || $originalHeight == 0) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// File Name without EXT type or Path |
|
|
|
|
$fileNameWithoutExt = pathinfo($uploadName, PATHINFO_FILENAME); |
|
|
|
|
|
|
|
|
|
$type = match($imageType) { |
|
|
|
|
IMAGETYPE_JPEG => '.jpg', |
|
|
|
|
IMAGETYPE_PNG => '.png', |
|
|
|
|
IMAGETYPE_GIF => '.gif', |
|
|
|
|
default => false, |
|
|
|
|
}; |
|
|
|
|
if ($type === false) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$success = rename($uploadName, $GLOBALS['uploadDir'] . 'orignal_' . $rndFile . '_' . $fileNameWithoutExt . $type); |
|
|
|
|
return ($success) ? 'orignal_' . $rndFile . '_' . $fileNameWithoutExt . $type : false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function get_size(int $target, int $original): int { |
|
|
|
|
@ -80,7 +99,10 @@ function image_compression(string $uploadName, string $fileName, array $images): |
|
|
|
|
} |
|
|
|
|
$a_of_images[] = $file; |
|
|
|
|
} |
|
|
|
|
rename_upload($uploadName, $fileName, $rnd_name); |
|
|
|
|
$org_file = rename_upload($uploadName, $fileName, $rnd_name); |
|
|
|
|
if ($org_file !== false) { |
|
|
|
|
$a_of_images[] = $org_file; |
|
|
|
|
} |
|
|
|
|
return $a_of_images; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|