Warning: Parameter 1 to wp_default_scripts() expected to be a reference, value given in /home/webgalli/public_html/blog/wp-includes/plugin.php on line 571

Warning: Parameter 1 to wp_default_scripts() expected to be a reference, value given in /home/webgalli/public_html/blog/wp-includes/plugin.php on line 571
Getting file extension with PHP - Team Webgalli Blog - Team Webgalli Blog
Request quote

Getting file extension with PHP

Posted on: January 20th, 2012 by Mahin No Comments

Here is a simple code snippet to get the extension of uploaded file via php

1] Method 1

$File_name = $_FILES['upload']['name'];
echo $File_extn = substr($File_name, strrpos($File_name, '.')+1);

2] Method 2

Using php’s pathinfo()

echo $ext = pathinfo($filename, PATHINFO_EXTENSION);
Tags: