查找上载文件的扩展名(PHP) [英] Finding Extension of uploaded file (PHP)

查看:69
本文介绍了查找上载文件的扩展名(PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
是什么在PHP中获取上传文件扩展名的最佳方法/做法

Possible Duplicate:
What's the best way/practice to get the extension of a uploaded file in PHP

我们可以从$ _FILES ["file"] ["tmp_name"]找出原始文件的扩展名吗?例如jpg或png等?谢谢.

Can We find out the extension of the original file from the $_FILES["file"]["tmp_name"] ? For example jpg or png etc? Thanks.

推荐答案

$name = $_FILES["file"]["name"];
$ext = end((explode(".", $name))); # extra () to prevent notice

echo $ext;

这篇关于查找上载文件的扩展名(PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆