Is there any method of obtaining the name of the file uploaded to a server without extension, in PHP? I used the $_FILES['file']['name']
but it returns the extension too.
Asked
Active
Viewed 2.4k times
11
-
wow you get 5 seperate answers/methods that all do the same thing! happy days! – fire Nov 14 '11 at 15:42
6 Answers
3
Use PHP basename() function.
string basename ( string $path [, string $suffix ] )

Riz
- 9,703
- 8
- 38
- 54
1
Yes, you can do it as:
$filenameOnly = array_pop(array_reverse(explode(".", $yourfilename)));
Hope that helps

Sudhir Bastakoti
- 99,167
- 15
- 158
- 162