php method to hide the real address of the picture: use base64 encoding to hide the real address of the picture, the code is [$file = file_get_contents($file['tmp_name']);$data = base64_encode($file);] .
php method to hide the real address of the picture:
PHP can use base64 encoding to hide the real address of the picture. After hiding, the image address in this format will be displayeddata:QUFodHRwOi8vd3d3LmJhaWR1
. Websites such as Xiang Moubao currently use this method, and it can improve the loading speed. The specific PHP code can be as follows:
0) exit('上传失败'); if (!in_array($ext, $dataType)) exit('图片格式错误'); $file = file_get_contents($file['tmp_name']); $data = base64_encode($file); echo 'data:image/'.$ext.';base64,'.$data; } else { ?>图片base64编码
Related free learning recommendations:php programming(video)
The above is the detailed content of How to hide the real address of pictures in php. For more information, please follow other related articles on the PHP Chinese website!