protected function createFromBase64($filename, $data)
    {
        // Get temporary destination
        $destination = sys_get_temp_dir() . '/' . str_random(4) . '-' . $filename;

        // Create destination if not already there
        if (is_dir(dirname($destination)) === false) {
            mkdir(dirname($destination), 0755, true);
        }

        // Create temporary file
        file_put_contents($destination, base64_decode($data), 0);

        // Get mime type
        $mime_type = mime_content_type($destination);

        return new UploadedFile($destination, $filename, $mime_type);
    }