Home > Backend Development > PHP Tutorial > php文件上传获取文件扩展名,运行时会报提醒

php文件上传获取文件扩展名,运行时会报提醒

WBOY
Release: 2016-06-13 11:55:03
Original
845 people have browsed it

php文件上传获取文件扩展名,运行时会报提示
今天练习文件上传操作,但遇到一个很纠结的事

直接看代码:

文件上传页:index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><br /><html><br /><head><br /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><br /><title>Insert title here</title><br /></head><br /><body><br /><form method="post" action="test.php" enctype="multipart/form-data"><br />文件<input type="file" name="up1"/><br/><br /><input type="submit" value="上传"/><br /></form><br /></body><br /></html>
Copy after login


文件处理页:test.php
<br />foreach($_FILES as $v){			<br />	$info=pathinfo($v['name']);<br />	//var_dump($info);//查看$info中的信息;<br />	//exit;<br />	//echo $info['extentsion'];//报提示<br />	//exit;<br />	$v['ext']=$info['extension'];//得到文件扩展名<br />	$v['filename']=$info['filename'];//得到文件名<br />	echo $v['ext'];//能得到正确的扩展名<br />	exit;			<br />}<br />
Copy after login


事情是这样的, 当我echo $info['extension']总会报提示:Notice:  Undefined index: extentsion in D:\WW.......
我var_dump($info)时,里面确实有"extension"啊
但是,如上代码所示$v['ext']=$info['extension'];后,我echo $v['ext'];却能得到正确的后缀名
这到底什么情况??

------解决方案--------------------
//echo $info['extentsion'];//报提示
echo $info['extension'];//报提示
注意拼写啊 少年 怎么可能会有错误呢

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template