Simply read the image from one of the image libraries , and then programmatically draw it. Example for JPEG image using GD :
$img = imagecreatefromjpeg('upload/avatar.jpg'); //Считываем изображение из загруженного //файла imagejpeg($img); //Рисуем считанное изображение imagejpeg($img, 'profile/avatar.jpg'); //Сохраняем считанное изображение в файл imagedestroy($img); //Освобождаем переменную
At the same time, all third-party files hidden in the image will be lost, and all that remains is to remove the source image from upload/
.
You should also remember about properly configured permissions:
chmod('profile/avatar.jpg', 0600); //НЕ исполняемый файл, запись и чтение только для владельца
In conjunction with the launch of the server on behalf of a separate system user: Even if an executable file was in the image, it cannot be launched, since this is directly prohibited by file permissions. In addition, third-party programs will not be able to change the image after the download, as only the user on whose behalf the file was created has rights to it.
It is not necessary to output through imagejpeg
images that have already been processed from profile/
, by this you generate an excessive load on the server, then you can get by with regular HTML. As a last resort, save the date of the last file change, after the installation of the rights, and check if it has changed.