How to Get Filename from Path in 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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- PHP MySQL Column Sorting Example Tutorial
- PHP MySQL Login with Google Account Example
- How to Create Dynamic Sitemap in Codeigniter?
- PHP Ajax Multiple Image Upload with Preview Example
- PHP MySQL Confirmation Before Delete Record using Ajax Example
- Codeigniter Ajax Infinite Scroll Pagination Example
- PHP MySQL Highcharts Chart Example
- How to Get File Name without Extension in PHP?
- File Upload with Progress Bar using jQuery Ajax and PHP Example
- How to Get a Current Page URL in PHP?
- How to Check File is Exists or Not in PHP?
- Mediafire PHP File Uploading and Get Link Example
- How to Convert Object into Array in PHP?
- How to Remove Null Values from Array in PHP?