<?php
$htmlUrl = "https://faberlic.com/index.php?option=com_flform&idform=514";
// Fetch the HTML code
$html = file_get_contents($htmlUrl);
if (!$html) {
die("Failed to fetch HTML code from $htmlUrl");
}
// Extract the image information
if (!preg_match('/<img data-type="lang" class="og-image" id="registration-img" style="max-width: 100%;\s*text-align: center; display: none;" src="(.*\.jpg\?v=.*?)" alt="Registration" \/>/', $html, $matches)) {
die("Failed to extract image URL from HTML code");
}
$imageUrl = $matches[1];
// Fetch the image and save it to a temporary file
$tempImage = tempnam(sys_get_temp_dir(), "image");
$imageData = file_get_contents($imageUrl);
if (!$imageData) {
die("Failed to fetch image data from $imageUrl");
}
file_put_contents($tempImage, $imageData);
// Display the image
if (!is_file($tempImage)) {
die("Failed to create temporary image file");
}
header("Content-Type: image/jpeg");
readfile($tempImage);
// Delete the temporary file
unlink($tempImage);
?>
may have misdescribed preg_match. i am noob in php.