Php 这对我来说很有用,但也需要它来做mp4和avi
下面的代码在图像文件中适用,我需要添加什么才能使其显示.avi和.mp4文件Php 这对我来说很有用,但也需要它来做mp4和avi,php,html,mp4,avi,Php,Html,Mp4,Avi,下面的代码在图像文件中适用,我需要添加什么才能使其显示.avi和.mp4文件 <?php $files = glob("images/*.*"); for ($i=0; $i<count($files); $i++) { $image = $files[$i]; $supported_file = array( 'gif', 'jpg', 'jpeg',
<?php
$files = glob("images/*.*");
for ($i=0; $i<count($files); $i++)
{
$image = $files[$i];
$supported_file = array(
'gif',
'jpg',
'jpeg',
'png'
);
$ext = strtolower(pathinfo($image, PATHINFO_EXTENSION));
if (in_array($ext, $supported_file)) {
echo basename($image)."<br />"; // show only image name if you want to show full path then use this code // echo $image."<br />";
echo '<img src="'.$image .'" alt="Random image" />'."<br /><br />";
} else {
continue;
}
}
?>
.avi
和.mp4
文件是视频,而不是图像,因此您应该为它们输出一个
标记:
<?php
$files = glob("images/*.*");
for ($i=0; $i<count($files); $i++)
{
$image = $files[$i];
$supported_file = array(
'gif',
'jpg',
'jpeg',
'png',
'avi',
'mp4',
);
$videos = [ 'avi', 'mp4' ];
$ext = strtolower(pathinfo($image, PATHINFO_EXTENSION));
if (in_array($ext, $supported_file)) {
echo basename($image)."<br />"; // show only image name if you want to show full path then use this code // echo $image."<br />";
if ( in_array( $ext, $videos )) {
echo '<video width="320" height="240" controls><source src="' . $image . '" type="video/mp4"></video>';
} else {
echo '<img src="'.$image .'" alt="Random image" />'."<br /><br />";
}
} else {
continue;
}
}
?>
有关
标记的详细信息:.avi
和.mp4
文件是视频,而不是图像,因此您应该为它们输出
标记:
<?php
$files = glob("images/*.*");
for ($i=0; $i<count($files); $i++)
{
$image = $files[$i];
$supported_file = array(
'gif',
'jpg',
'jpeg',
'png',
'avi',
'mp4',
);
$videos = [ 'avi', 'mp4' ];
$ext = strtolower(pathinfo($image, PATHINFO_EXTENSION));
if (in_array($ext, $supported_file)) {
echo basename($image)."<br />"; // show only image name if you want to show full path then use this code // echo $image."<br />";
if ( in_array( $ext, $videos )) {
echo '<video width="320" height="240" controls><source src="' . $image . '" type="video/mp4"></video>';
} else {
echo '<img src="'.$image .'" alt="Random image" />'."<br /><br />";
}
} else {
continue;
}
}
?>
有关
标记的详细信息:将视频标记用于mp4,avi将无法在web浏览器中工作。将视频标记用于mp4,avi将无法在web浏览器中工作。