public static function uploadImage($file, $location) { if ($file && $location) { $user = CustomLoginProvider::getLoggedInUser(); $info = pathinfo($file); $discussion = new Image(); $discussion->UploadedBy = $user->UserID; $discussion->save(); $discussion->Source = '/static/images/uploaded/' . $discussion->UniqueIdentifier . '.' . $info['extension']; if (!is_dir('static/images/uploaded/')) { mkdir('static/images/uploaded', 0777, true); } $discussion->save(); rename($location, 'static/images/uploaded/' . $discussion->UniqueIdentifier . '.' . $info['extension']); ImageResize::resizeIntoMultipleFormats($discussion->UniqueIdentifier . '.' . $info['extension'], 'static/images/uploaded/'); self::$createdImagesForGallery[] = $discussion->ImageID; } }
<?php chdir(__DIR__); include_once '../Helpers/ImageResize.php'; $dirs = ['../../static/images/uploaded/', '../../static/images/usrimgs/']; foreach ($dirs as $dir) { $files = scandir($dir); foreach ($files as $file) { if (!is_dir($file)) { \Your\WebApp\Helpers\ImageResize::resizeIntoMultipleFormats($file, $dir); } } }