I make a form through i can upload images and videos, the file's are stor in some folder and the path is stored in mysql table, now when i select the image file then i would show properly, my image selection code is...
$smt=$conn->prepare('SELECT * FROM post');
$smt->execute();
<?php while($gdata=$smt->fetch(PDO::FETCH_OBJ)):?>
<a href="#" class="media-left col-md-4 clearfix"><img src="posts/<?php echo $gdata->Post_Path; ?>" alt="image" class="post-image"/></a>
<div class="media-body col-md-8 post-image-space pull-left">
<div class="post-overview">
<ul>
<li class="post-category"><?php echo $gdata->Category;?></li>
<li class="post-timestemp">Post on <?php echo $gdata->Post_Date;?></li>
</ul>
<a href="post-description.php?id=<?php echo $gdata->Id?>"><h4 class="media-heading h4"><?php echo $gdata->Title;?></h4></a>
<p class="post-text"><?php echo $gdata->Post;?></p>
</div>
</div>
<?php endwhile;?>
now the problem is that through the above way i can access the video file but it can't be shown? How can i check that the file is image or video?
In my database the path will store like, example.jpg/mypic.png, test.mp4, how can i check the last extension of file?
my updated code is...
<?php
include 'conn.php';
$smt=$conn->prepare('SELECT * FROM post');
$smt->execute();
$row=$smt->fetch(PDO::FETCH_OBJ);
$row->Post_Path;
$ext=pathinfo($row,PATHINFO_EXTENSION);
?>
<?php if($ext=='mp4')
{?>
<?php while($gdata=$smt->fetch(PDO::FETCH_OBJ)):?>
<a href="#" class="media-left col-md-4 clearfix"><video class="post-image" controls>
<source src="posts/<?php echo $gdata->$ext;?>" type="video/mp4">
</video></a>
<div class="media-body col-md-8 post-image-space pull-left">
<div class="post-overview">
<ul>
<li class="post-category"><?php echo $gdata->Category;?></li>
<li class="post-timestemp">Post on <?php echo $gdata->Post_Date;?></li>
</ul>
<a href="post-description.php?id=<?php echo $gdata->Id?>"><h4 class="media-heading h4"><?php echo $gdata->Title;?></h4></a>
<p class="post-text"><?php echo $gdata->Post;?></p>
</div>
</div>
<?php endwhile;
}
elseif($ext=='jpg||jpeg||png')
{
?>
<?php while ($gdata = $smt->fetch(PDO::FETCH_OBJ)): ?>
<a href="#" class="media-left col-md-4 clearfix"><img src="posts/<?php echo $gdata->Post_Path; ?>" alt="image"
class="post-image"/></a>
<div class="media-body col-md-8 post-image-space pull-left">
<div class="post-overview">
<ul>
<li class="post-category"><?php echo $gdata->Category; ?></li>
<li class="post-timestemp">Post on <?php echo $gdata->Post_Date; ?></li>
</ul>
<a href="post-description.php?id=<?php echo $gdata->Id ?>"><h4
class="media-heading h4"><?php echo $gdata->Title; ?></h4></a>
<p class="post-text"><?php echo $gdata->Post; ?></p>
</div>
</div>
<?php endwhile;
}?>
I am not able to show video in my index page, how to show it, however i am able to show the image..
Any help would be appreciated.