If you want to obtain just the name of the file, you could also do it as follows:
<?php
$file = 'folder1/folder2/image.jpg';
$file_name = substr($file, strrpos($file, '/') + 1, strrpos($file, '.') - strrpos($file, '/') - 1);
echo $file_name; // Will output "image".