为什么我用php写的文件上传程序中 $_FILES['file']['tmp_name'] 的输出为空?
代码如下:
<form action="__URL__/{$btn_ok_act}" method="post" enctype="multipart/form-data" name="upload">
<h3>产品名</h3>
<h3> 产品图片:</h3>
<br>
<input type="file" name="file" value="浏览"/>
<input type="submit" name="submit" value="{$btn_ok_text}"/>
</form>
后台处理:
public function add() {
header("Content-Type:text/html; charset=utf-8");
//图片上传
$type=array("jpg","gif","bmp","jpeg","png"); //图片的类型
$uploaddir="/ThinkPHP_APP/Public/upload/image/";
echo $_FILES['file']['tmp_name']; //这里为什么输出为空,且跳转到这一步了
echo $_FILES['file']['name']; //这个就可以输出,怎么解释,php.ini中也设置了 upload_tmp_dir ="C:/Windows/Temp/"
$image_file=$_FILES['file']['name'];
$image_tmp=$_FILES['file']['tmp_name'];
$uptype=strtolower(substr(strrchr($image_file,'.'), 1));
if(!in_array($uptype, $type)){
$this->error('您选的图片不符合类型');
}
$uploadimage=$uploaddir.$image_file;