Evening all.
I am goign through my Image upload script and found it looks messy, would you recommend an cleaner way of doing this:
move_uploaded_file($_FILES['file']['tmp_name'], 'photos/' . $_FILES['file']['name']);
try {
$fileName = $_FILES['file']['name'];
$resizeObj = new resize('photos/' . $fileName);
// *** Resize options: exact, portrait, landscape, auto, crop
$resizeObj->resizeImage(225, 150, 'auto');
$extension = strtolower(strrchr($fileName, '.')); // extract file extension
$clean = str_replace($extension, '', $fileName); // replace file extension with nothing -> removes
$resizeObj->saveImage('photos/' . $clean . '.png', 100);
unlink('photos/' . $fileName);
} catch (Exception $e) {
echo 'Error ' . $e->getMessage() . "\n";
}
I have tried parsing the $_FILES['file']['name']
directly into the resize
class but this does do anything, hence i save the original -> modify the size -> strip the extension -> save as png -> delet original
Any input is greatly appreciated.
Squidge