Are you creating an application in which you require a functionality that will copy the file from a given URL and then store into a directory and while coping the file you want to get filename of from given URL and then you want rename that according to your requirement. Am I right? Here, I an going to write a code that will help us to get file name from a URL using PHP inbuilt function basename().
Here is the code:
<?php echo basename("http://example.com/image.png"); ?>
Above code will output the file name as 'image.png'.