简体   繁体   中英

download using thumbnails in php

hey guys i am developing a tutorial website in php.I have uploaded few videos on my server and want them to be made available to users. What i want is the download page to display the thumbnail of the videos(with the name and link of video) and when user clicks on the thumbnail they should be directed to a new page so that user can view, comment and rate the videos(similar to you tube).Can anybody tell me how to show thumbnail of the video and how to redirect the user to a new page on clicking the thumbnail.

I was able to provide the links to the user for streaming but on clicking the links, video was playing on the same page using this code

<?php
  $yourDirectory = "../path/to/your/directory/";
  if (is_dir($yourDirectory ))
  {
    if ($reading = opendir($yourDirectory))
    {
      while (($files = readdir($reading)) !== false)
      {
        if( $files != "." && $files != ".." && $files[0] != "." )
        {
          echo "<a href='fancybox'><img src='$files' alt='' /></a>";
        }
      }
      closedir($reading);
   }
 }
?>

You're going to need an image processor like GD or ImageMagick. This post should help .

It shows how to create thumbnails of a specified size using GD. The drawback is it takes some time and prepwork to make sure GD is installed on your system--but if you're using a hosted PHP environment, you may be in luck as most have them available to you.

As for opening your links in a new window, the "fancybox" might be messing you up. That's trying to play your video in a lightbox. You might consider removing fancybox and adding a

target="_new"

to your link, like

<a target="_new" href="/path/to/video.ext"><img src="/path/to/thumbnail.ext" /></a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM