04 January 2020

How to fetch file name, extension and basename from url in php?

Fetch file name, extension and basename from url in php

<?php
$file = 'http://localhost/brrrr/wp-content/uploads/2019/11/New-Business-card-4.jpg';
$ext = pathinfo($file);

echo $ext['dirname'] . '<br/>';   // Returns folder/directory
echo $ext['basename'] . '<br/>';  // Returns file.html
echo $ext['extension'] . '<br/>'; // Returns .html
 echo $ext['filename'] . '<br/>';  // Returns file 
?>

No comments:

Post a Comment

How to create youtube videos slider with play and pause option in wordpress?

Create youtube videos slider with play and pause option in wordpress youtube videos slider Use this shortcode:- [punjab_today] function my_...