Advertisement
MizunoBrasil

php youtube thumbnail download

Feb 5th, 2023
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
  8.     <title>Document</title>
  9. </head>
  10. <body>
  11.     <br><br><br>
  12.     <div class="container">
  13.     <center><h4>Baixar Thumb do Youtube</h4>
  14.     <img src="youtube-logo.png" width="100"></center>
  15.     <br><br>
  16.         <form action="download.php" method="post">
  17.    <div class="form-group">    
  18.     <input type="text" class="form-control" name="video_id" required placeholder="Digite o ID do vídeo">
  19.    </div>
  20.   <input type="submit" class="btn btn-primary" value="Baixar Thumbnail">
  21. </form>
  22.  
  23.     </div>
  24.    
  25. </body>
  26. </html>
  27.  
  28.  
  29.  
  30.  
  31.  
  32. download.php
  33.  
  34. <?php
  35. if (isset($_POST['video_id'])) {
  36.   $video_id = $_POST['video_id'];
  37.   $thumbnail_url = "https://img.youtube.com/vi/$video_id/maxresdefault.jpg";
  38.   $unique_name = uniqid() . '.jpg';
  39.  
  40.   header('Content-Type: image/jpeg');
  41.   header("Content-Disposition: attachment; filename=$unique_name");
  42.   readfile($thumbnail_url);
  43. }
  44. ?>
  45.  
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement