php获取上传文件名的文件类型
php教程获取上传文件名的文件类型
$imgname = $_FILES["file"]["name"]; //获取上传的文件名称 $filetype = pathinfo($imgname, PATHINFO_EXTENSION);//获取后缀 $newname = date("Ymdhis").".".$filetype; //构建新名称
再看
$file = 'www.phprm.com.gif'; echo getfix( $file );
//得到的值为gif 这种方法最简单也最实例了,好下面我们来看看方法二一种用substr读取扩展名方法
$file ='aaa.gif'; echo substr($file,strpos($file,'.')+1);
//方法三 还是用数组
$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);//获取文件扩展名
strpos() 函数返回字符串在另一个字符串中第一次出现的位置。如果没有找到该字符串,则返回 false。
更多详细内容请查看:http://www.phprm.com
本文地址:http://www.phprm.com/base/39774.html
转载随意,但请附上文章地址:-)