简体   繁体   English

在php中使用缩略图下载

[英]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. 大家好,我正在用php开发一个教程网站。我已经在服务器上上传了一些视频,并希望将其提供给用户。 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. 您将需要诸如GD或ImageMagick的图像处理器。 This post should help . 这篇文章应该有所帮助

It shows how to create thumbnails of a specified size using GD. 它显示了如何使用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. 缺点是要确保在系统上安装了GD需要花费一些时间和准备工作-但如果您使用的是托管PHP环境,则可能会很幸运,因为大多数人都可以使用它们。

As for opening your links in a new window, the "fancybox" might be messing you up. 至于在新窗口中打开链接,“ fancybox”可能会让您感到困惑。 That's trying to play your video in a lightbox. 试图在灯箱中播放视频。 You might consider removing fancybox and adding a 您可以考虑删除fancybox并添加一个

target="_new"

to your link, like 到您的链接,例如

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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