src/Aptoma/Ftp/Ftp.php
public function verifyAndMoveUploadedFile(
        $originSize,
        $tmpDestination,
        $publicDestination
    ) {
        $remoteTempSize = $this->getSize($tmpDestination);
        $this->logger->debug('Temp size: ' . $remoteTempSize);
        $this->logger->debug('Origin size: ' . $originSize);
        if ($remoteTempSize <= 0) {
            throw new VerifySizeException('Uploaded file has size ' . $remoteTempSize);
        }

        if ($remoteTempSize !== $originSize) {
            throw new VerifySizeException(
                sprintf(
                    'Uploaded file has wrong size. Expected %s, got %s.',
                    $originSize,
                    $remoteTempSize
                )
            );
        }

        $this->logger->info('OK: Uploaded temp file has right size.');
        if (!$this->move($tmpDestination, $publicDestination)) {
            throw new FtpException('Error renaming uploaded file from temp to public.');
        }

        $remotePublicSize = $this->getSize($publicDestination);
        $this->logger->debug('Renamed size: ' . $remotePublicSize);
        if ($remotePublicSize <= 0) {
            throw new VerifySizeException('Renamed file has size ' . $remotePublicSize);
        }

        if ($remotePublicSize !== $originSize) {
            throw new VerifySizeException(
                sprintf(
                    'Renamed file has wrong size. Expected %s, got %s.',
                    $originSize,
                    $remotePublicSize
                )
            );
        }
        $this->logger->info('OK: Renamed file has right size.');

        return true;
    }
public function verifyAndMoveUploadedFile(
        $originSize,
        $tmpDestination,
        $publicDestination
    ) {
        $remoteTempSize = $this->getSize($tmpDestination);
        $this->logger->debug('Temp size: ' . $remoteTempSize);
        $this->logger->debug('Origin size: ' . $originSize);
        if ($remoteTempSize <= 0) {
            throw new VerifySizeException('Uploaded file has size ' . $remoteTempSize);
        }

        if ($remoteTempSize !== $originSize) {
            throw new VerifySizeException(
                sprintf(
                    'Uploaded file has wrong size. Expected %s, got %s.',
                    $originSize,
                    $remoteTempSize
                )
            );
        }

        $this->logger->info('OK: Uploaded temp file has right size.');
        if (!$this->move($tmpDestination, $publicDestination)) {
            throw new FtpException('Error renaming uploaded file from temp to public.');
        }

        $remotePublicSize = $this->getSize($publicDestination);
        $this->logger->debug('Renamed size: ' . $remotePublicSize);
        if ($remotePublicSize <= 0) {
            throw new VerifySizeException('Renamed file has size ' . $remotePublicSize);
        }

        if ($remotePublicSize !== $originSize) {
            throw new VerifySizeException(
                sprintf(
                    'Renamed file has wrong size. Expected %s, got %s.',
                    $originSize,
                    $remotePublicSize
                )
            );
        }
        $this->logger->info('OK: Renamed file has right size.');

        return true;
    }
Verify that uploaded file is the same as origin file, and if so, move to public folder

@param $originSize
@param $tmpDestination
@param $publicDestination
@return bool
@throws FtpException
@throws VerifySizeException