ItSolutionStuff.com

How to Get Filename from Path in PHP?

By Hardik Savani β€’ May 14, 2024
PHP

Hello Folks,

Today, php get filename from url is our main topic. This example will help you php get image filename from url. This article will give you a simple example of php url basename. let’s discuss about get image name from url php.

Sometimes, we may require to get only filename or image name from full path or url in your PHP project or any framwwork project at that time you can get file name using php pre-define function basename.

If you ever use this function then you can see as bellow example how it's works. I have one image url like, i want to just get image name then you can get image name like this way :

index.php

<?php

$name = basename("https://itsolutionstuff.com/upload/Laravel-5-Mailgun.png");

echo $name;

?>

Output:

Laravel-5-Mailgun.png

I hope it can help you...

Tags: PHP
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

πŸ“Ί Subscribe on YouTube

We Are Recommending You

β˜…

PHP MySQL Column Sorting Example Tutorial

Read Now β†’
β˜…

PHP MySQL Login with Google Account Example

Read Now β†’
β˜…

How to Create Dynamic Sitemap in Codeigniter?

Read Now β†’
β˜…

PHP Ajax Multiple Image Upload with Preview Example

Read Now β†’
β˜…

PHP MySQL Confirmation Before Delete Record using Ajax Example

Read Now β†’
β˜…

Codeigniter Ajax Infinite Scroll Pagination Example

Read Now β†’
β˜…

PHP MySQL Highcharts Chart Example

Read Now β†’
β˜…

How to Get File Name without Extension in PHP?

Read Now β†’
β˜…

File Upload with Progress Bar using jQuery Ajax and PHP Example

Read Now β†’
β˜…

How to Get a Current Page URL in PHP?

Read Now β†’
β˜…

How to Check File is Exists or Not in PHP?

Read Now β†’
β˜…

Mediafire PHP File Uploading and Get Link Example

Read Now β†’
β˜…

How to Convert Object into Array in PHP?

Read Now β†’
β˜…

How to Remove Null Values from Array in PHP?

Read Now β†’