PHP从图像中删除Exif数据 [英] PHP remove exif data from images
本文介绍了PHP从图像中删除Exif数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用PHP从图像中删除EXIF数据是否足以防止在服务器中执行恶意代码?
Is deleting the EXIF data from images using PHP enough to prevent malicious codes from being executed in a server?
推荐答案
这将向您显示PHP中JPEG文件中的EXIF信息.
This will show you EXIF information from JPEG file in PHP.
$uploadfile = "uploaded/pic.jpg";
$exif = exif_read_data($uploadfile, 0, true);
echo "<b>Your file</b><br />\n";
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
echo "$key.$name: $val<br />\n";
}
}
这段代码应该删除所有EXIF信息
And this piece of code should delete all EXIF information
$img = new Imagick($uploadfile);
$img->stripImage();
$img->writeImage($uploadfile);
您可以在这里尝试: https://iconnaut.com/exif.php
You can try it here: https://iconnaut.com/exif.php
这篇关于PHP从图像中删除Exif数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文