В конечном итоге я не получил особой помощи или поддержки в этом опубликованном вопросе, но наконец-то получил его, и это был окончательный результат:
/** Create Thumbnails For Images Uploaded */
function createThumbnail($imagesName, $thumbWidth, $thumbHeight, $imagesDir,
$thumbsDir) {
$imagesSource = $imagesDir."/".$imagesName;
$thumbImages = $thumbsDir."/".$imagesName;
list($width,$height) = getimagesize($imagesSource);
$thumb = imagecreatetruecolor($thumbWidth, $thumbHeight);
if(preg_match('/[.](jpg|jpeg)$/i', $imagesName)) {
$image_source = imagecreatefromjpeg($imagesSource);
} else if (preg_match('/[.](png)$/i', $imagesName)) {
$image_source = imagecreatefrompng($imagesSource);
} else {
$image_source = imagecreatefromjpeg($imagesSource);
}
imagecopyresized($thumb, $image_source, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $width,
$height);
if(preg_match('/[.](jpg|jpeg)$/i', $imagesName)) {
imagejpeg($thumb,$thumbImages, 65);
} else if (preg_match('/[.](png)$/i', $imagesName)) {
imagepng($thumb, $thumbImages, 5);
} else {
imagejpeg($thumb, $thumbImages, 65);
}
}
/** Upload An Image Or Multiple Images And Setup Errors */
$uploadedImages = array();
$errors = array();
$extension = array("jpeg", "jpg", "png", "JPEG", "JPG", "PNG");
$bytes = 2048;
$KB = 2048;
$totalBytes = $bytes * $KB;
$counter = 0;
$imagesDir = GALLERY_IMG_PATH."/".GALLERY_IMG_FULLSIZE."/";
$thumbsDir = GALLERY_IMG_PATH."/".GALLERY_IMG_THUMB."/";
if(isset($_FILES["images"]["tmp_name"])) {
foreach($_FILES['images']['name'] as $key=>$val) {
$imagesName = str_replace(" ", "_", $_FILES['images']['name'][$key]);
$thumbSource = GALLERY_IMG_PATH.GALLERY_IMG_FULLSIZE."/".$imagesName;
$counter++;
$UploadOk = true;
if($_FILES["images"]["size"][$key] > $totalBytes) {
$UploadOk = false; // Size Limitation Per Image
array_push($errors, $imagesName." file size is larger than the 2MB. You must upload
images smaller than 2MB.");
}
$ext = strtolower(pathinfo($imagesName, PATHINFO_EXTENSION));
if(in_array($ext, $extension) == false) {
$UploadOk = false; // Image Extensions Handled/Accepted
array_push($errors, $imagesName." has an invalid image extension. Images must contain
only these extensions: *.jpeg | *.jpg | *.png");
header("Location: Admin?admin_action=editGallery&error=invalidExtension");
}
if(file_exists(GALLERY_IMG_PATH."/".GALLERY_IMG_FULLSIZE."/".$imagesName) == true) {
$UploadOk = false; // Prevent Image/Images Uploaded With Same Name
array_push($errors, "You attempted to upload an image that is already uploaded/the
image name conflicts with an image that already uses the name:".$imagesName.". If it's
not a duplicate image than simply rename it to have a unique difference.");
}
if($UploadOk == true) { // No Errors Occurred: Execute Upload & Create Thumbnail
if(move_uploaded_file($_FILES['images']['tmp_name'][$key], $imagesDir.$imagesName)) {
array_push($uploadedImages, $imagesName);
$imagesSource = $imagesDir."/".$imagesName;
list($width,$height) = getimagesize($imagesSource);
$thumbWidth = 290;
$thumbHeight = intval ($height / $width * $thumbWidth);
createThumbnail($imagesName, $thumbWidth, $thumbHeight, $imagesDir, $thumbsDir);
}
}
}
}