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
?>
Comments
Post a Comment