How to get folder path from file path in PHP?

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Today now in this post i will show you How to get folder path from file path in PHP? Sometimes, we need to get the directory path from Image path or the file url in our PHP application or any PHP framework application at that time we can get the folder name by using php pre-define function dirname.

So if we are ever use this function then we can see as the bellow example how it’s works. Now I need to one image url as like, i want to just get the folder path then we can get folder path as like this way :

Example:
dirname('http://localhost:8000/upload/images/test.jpg');

Read Also : How to Create Custom Blade Directive in Laravel?

Thanks for read. I hope it help you. For more you can follow us on facebook.

About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →