How to Get Folder Path from File Path in PHP?
Sometimes, we require to get directory path from Image path or file url in our PHP website or any PHP framework website at that time we can get folder name using php pre-define function dirname.
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 folder path then you can get folder path like this way :
index.php
<?php
$name = dirname("https://itsolutionstuff.com/upload/Laravel-5-Mailgun.png");
echo $name;
?>
Output:
upload
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 Webcam Capture Image and Save from Camera
- PHP JQuery Chosen Ajax Autocomplete Example
- Dynamic Dependent Dropdown using VueJS and PHP
- PHP Ajax Multiple Image Upload with Preview Example
- PHP MySQL Confirmation Before Delete Record using Ajax Example
- PHP Ajax Form Validation Example Tutorial
- PHP MySQL DataTables Server-side Processing Example
- PHP MySQL Image Gallery CRUD Example
- PHP Ajax Infinite Scroll Pagination Example
- PHP Import Excel File into MySQL Database Tutorial
- PHP Crop Image Before Upload using Croppie JS Example
- How to Remove Duplicate Values from Array in PHP?
- How to Remove White Space from String in PHP?