-2

I have this URL and I want to remove all characters before "blog_images/" this world.

http://localhost/login/uploads/blog_images/woman4.jpg

I have tried this PHP function it removes all words but I want to remove this word also, I need to get only this characters woman4.jpg

strstr(http://localhost/login/uploads/blog_images/woman4.jpg, 'blog_images/');
Salman Iqbal
  • 442
  • 5
  • 23

2 Answers2

1

You can get file name using basename function php

<?php
/* $your_file_path_along_with_file_name is your input path */
$your_file_path_along_with_file_name = "http://localhost/login/uploads/blog_images/woman4.jpg";
$original_file_name = basename($your_file_path_along_with_file_name);
echo $original_file_name //it prints your file name
?>
-1

you can use explode like this,

$dat = explode('blog_images/','http://localhost/login/uploads/blog_images/woman4.jpg');

echo $dat[1];