<?php
if
(isset(
$_POST
[
'button'
])) {
$img_URl
=
$_POST
[
'img-url'
];
$c_URL
= curl_init(
$img_URl
);
curl_setopt(
$c_URL
, CURLOPT_RETURNTRANSFER, 1);
$download_Img
= curl_exec(
$c_URL
);
curl_close(
$c_URL
);
header(
'Content-type: image/jpg'
);
header(
'Content-Disposition: attachment;filename="yt-thumbnail.jpg"'
);
echo
$download_Img
;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Download YouTube Video Thumbnail</title>
<link rel=
"stylesheet"
href=
"style.css"
>
<!-- For using icons from font awesome -->
</head>
<body>
<!-- Form
for
submitting the youtube video url -->
<form action=
"<?php echo $_SERVER['PHP_SELF']; ?>"
method=
"POST"
>
<header>Download YouTube Thumbnail</header>
<!-- Input section -->
<div
class
=
"url-input"
>
<span
class
=
"heading"
>Paste video url:</span>
<div
class
=
"input-field"
>
<input
class
=
"hidden-input"
type=
"hidden"
name=
"img-url"
>
<span
class
=
"bottom-line"
></span>
</div>
</div>
<!-- Preview section -->
<div
class
=
"preview-area"
>
<img
class
=
"thumbnail"
src=
""
alt=
""
>
<i
class
=
"icon fa-solid fa-play"
></i>
<span>Paste video url to see preview</span>
</div>
<!-- Download button -->
<button
class
=
"download-button"
type=
"submit"
name=
"button"
>Download Thumbnail</button>
</form>
<script src=
"script.js"
></script>
</body>
</html>