ItSolutionStuff.com

How to Get Folder Path from File Path in PHP?

By Hardik Savani • May 14, 2024
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: 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 Webcam Capture Image and Save from Camera

Read Now →

PHP JQuery Chosen Ajax Autocomplete Example

Read Now →

Dynamic Dependent Dropdown using VueJS and PHP

Read Now →

PHP Ajax Multiple Image Upload with Preview Example

Read Now →

PHP MySQL Confirmation Before Delete Record using Ajax Example

Read Now →

PHP Ajax Form Validation Example Tutorial

Read Now →

PHP MySQL DataTables Server-side Processing Example

Read Now →

PHP MySQL Image Gallery CRUD Example

Read Now →

PHP Ajax Infinite Scroll Pagination Example

Read Now →

PHP Import Excel File into MySQL Database Tutorial

Read Now →

PHP Crop Image Before Upload using Croppie JS Example

Read Now →

How to Remove Duplicate Values from Array in PHP?

Read Now →

How to Remove White Space from String in PHP?

Read Now →