How to Get Folder Path from File Path in PHP?

By Hardik Savani May 14, 2024 Category : 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...

Tags :
Shares