$maxSize) { return false; } $fileParts = pathinfo($file['name']); $destinationFilename = sprintf("%s.%s", $unik, $fileParts['extension']); $destination = UPLOAD_IMAGES_MESSAGES.$destinationFilename; move_uploaded_file($file['tmp_name'], $destination); if (filesize ($destination) >$maxSize) { unlink($destination); return false; } $cmd = "convert -thumbnail 1200 $destination $destination"; exec($cmd); $urlThumb = self::createThumb(UPLOAD_IMAGES_MESSAGES_WIDTH, UPLOAD_IMAGES_MESSAGES_HEIGHT, $destination); return $urlThumb; } public static function createThumb($width, $height, $originalImagePath) { $finalImagePath = self::insertStringBeforeExtension($originalImagePath); //convert -thumbnail 200 abc.png thumb.abc.png $cmd = "convert -thumbnail $width $originalImagePath $finalImagePath"; exec($cmd); $url = UPLOAD_IMAGES_MESSAGES_URL.basename($finalImagePath); return $url; } }