[英]Convert Base64 to original image path
I'm using the following code to encode my image path. 我正在使用以下代码对图像路径进行编码。 I want to know if it is safe or someone can decode the original file path from encoded string?
我想知道它是否安全,或者有人可以从编码字符串中解码原始文件路径?
$imagedata = file_get_contents("ab/test.png");
$base64 = base64_encode($imagedata);
echo '<img src="data:image/jpeg;base64,'.$base64.'" />';
also do i have to use data:image/jpeg or png or gif or any extension would work? 我也必须使用data:image / jpeg或png或gif或任何扩展名都可以工作吗?
They can decode the data, but can't know what the original filename was. 他们可以解码数据,但不知道原始文件名是什么。 The encoded data contains just the image data, not its meta -data (as in filename, mime-type -not directly-, inode, etc).
编码后的数据仅包含图像数据,而不包含其元数据(如文件名,mime类型-不直接-,inode等)。
As per your second question: you must use the proper MIME type that matches the data, otherwise the browser/client won't understand its contents. 关于第二个问题:必须使用与数据匹配的正确MIME类型,否则浏览器/客户端将无法理解其内容。
您正在将文件内容加载到Base64编码的字符串中,所以不,它们无法获取路径,因为您仅提供了内容。
If by "safe" you mean reversible then no, it is not safe. 如果用“安全”来表示可逆,则不可以,这是不安全的。
Base64 encodes data which can be decoded easily with base64_decode. Base64编码的数据可以使用base64_decode轻松解码。 Someone would be able to decode your base64 data into the original image.
有人将能够将您的base64数据解码为原始图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.