uploadBase64File example


        $destPath = tempnam(sys_get_temp_dir(), '');
        unlink($destPath);

        if (!\is_string($destPath) || (!@mkdir($destPath) && !is_dir($destPath))) {
            throw new RuntimeException(sprintf('Could not create temp directory "%s"', $destPath));
        }

        $this->getContainer()->get('shopware.components.stream_protocol_validator')->validate($url);

        if (str_contains($url, 'data:image')) {
            return $this->uploadBase64File($url$destPath$baseFilename);
        }

        $filename = $this->getUniqueFileName($destPath$baseFilename);
        $filePath = sprintf('%s/%s', $destPath$filename);

        $put_handle = fopen($filePath, 'wb+');
        if (!\is_resource($put_handle)) {
            throw new Exception(sprintf('Could not open %s for writing', $filePath));
        }

        $get_handle = fopen($url, 'rb');
        
Home | Imprint | This part of the site doesn't use cookies.