我提到了这个stackoverflow响应如何预览上传的图像作为div的背景图像?
将背景图像设置为新上传的图像。
但这对我不起作用-这就是它所显示的:
<img id="urlimg" class="imageholder" style="background-image: url(data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBhIPEBQQEhQPFBAQDxAPFBQQDxAQEBAPFRAVFBQUFBQXHCYeFxkkGRQUHy8gIycpLCwsFR4xNTAqNSYrLCkBCQoKDgwOFw8PFCkdHBwpKSksKSkpKSkpKSkpKSwsLDUsLCkpKSkpKSwsNSkpNSopKSk1KSkpKTUsLDUqKSk1LP/AABEIAMIBAwMBIgACEQEDEQH/xAAcAAEAAgMBAQEAAAAAAAAAAAAABAUBAgMGBwj/xABBEAACAQICBwUDCwMCBwEAAAAAAQIDEQQhBRIxQVFxkQZhgaGxIjLRBxMUFUJSYnKCweEjkvAz8RdDU3OissIW/8QAGwEBAQEBAQEBAQAAAAAAAAAAAAECAwQGBQf/xAApEQEBAAEDAwMBCQAAAAAAAAAAARECAxIEITEFE1FBBiIyYXGRsdHh/9oADAMBAAIRAxEAPwD7iAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADnUrxjk2k9vec3jY8X0JkSARvpy4S6I5y0ml/uMwTQVstLru82c5aa/y38k5RcLYFK9Md76IfWv4pdByhhOr6QUJar2qzzdtpylpThbzZVaRr61b81KEuqEXkZ5d1wsJaUl3dDjPScuL62IkpHGUjNtXCVPSb7797ZZaKxd4Nyf2srvdZbDzGJq2aS2uUV1aRNqY6SyvkJqwWPSSxsFvI89NUlvvyaPhnbLHTqYuo3KbS1FFOTso6i2LncoHIxd/vjD6LpvQpvbenc93GZnx/r9CYrtfh6a9qdKP5qkV5FZ/wAScI5KKrU7t2uoz1bvjK1kfDkLmfer3aPs9sz8W5b+mJ/b9DvSje9+FjCxif2n4tnh+yGnPn8PFSd50kqcuLS92XivNM9HTqXOk1ZfK72xdnc1berzK9Fh8bxzXFE2Mk80eYhNrYSKelHB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5e/OpL9TiukbE4VbqjvWxsY+9KK5tIhz05T3Ny/JGUvO1iww3ZWO6F3yu+paYfss/u252Rr259anJ5aWlqj9ylPnOSj6XOuDwmNxMtWCpxW96raiu+Ty8j2uG7MwXvZ9y+JcUaMYLVikktyVkXjEzVRoHs2sN7U5yq1ms5Ssox7oRWS57S6ANIAAAAAAAAAAAAAAAAAAAAAAAArqkc3zfqaOJIqLN82c3EDk4mjgSY0W9iOscHxfQCudMwsO3sTLeOGit3XM6pAU60bJ7uuRvHQvFpclctQBAhoemtt35Emng4R2Rj0v6nYAYSMgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEWe/mb0YruMgDsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//Z); background-color: transparent; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">
然而,当我单击 chrome 控制台元素中的背景图像时,它会显示图像 - 因此图像已正确上传
我不相信 imageholder 类有什么问题,因为它在上传之前显示背景空白图像。
有人可以让我知道我可能做错了什么。
如果显示的背景图像显示为 ascii 流,是否存在任何安全风险?