Quantcast
Viewing latest article 17
Browse Latest Browse All 27

Reading extension of uploaded file in php | PHP Tutorials for Beginners

In this tutorial of php code for beginners we will show you how to fetch or read the extension of currently uploaded file.
There are two simple way to read the extension of file, one is by using the php string function and another is by user of fileinfo() function. Following example will show you the both way to read the extension of file.
1) $file_extension = strtolower(substr(strrchr($FILES['image']['name'],"."),1)); 

2) $file_extension = pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION);
By use of any of above code you will be able to read or get the extention any file.

Hope this php tutorial is useful for you. Keep following Php Tutorials for Beginners for more help.

Viewing latest article 17
Browse Latest Browse All 27

Trending Articles