php tutorial to get the file type of the uploaded file name
$imgname = $_FILES["file"]["name"]; //Get the uploaded file name
$filetype = pathinfo($imgname, PATHINFO_EXTENSION);//Get the suffix
$newname = date("Ymdhis").".".$filetype; //Build a new name
See you again
$file = 'www.bKjia.c0m.gif';
echo getfix( $file );
//The obtained value is gif. This method is the simplest and most practical. Let’s take a look at method 2 and one method of reading the extension using substr
$file ='aaa.gif';
echo substr($file,strpos($file,'.')+1);
//Method 3 still use array
$file = '111cn.gif';
$d111cn = explode('.',$file);
echo $d111cn[count($d111cn)-1];function getfix($l1){
return end(explode('.', $l1));
}
$extname=substr($upload_file_name,strpos($upload_file_name,".")+1);//Get the file extension
The strpos() function returns the position of the first occurrence of a string in another string. If the string is not found, returns false.
For more details, please see: http://www.bKjia.c0m/phper/21/358ad3dd52a90fd7894a1047adc80208.htm