<?php
//判断错误码
require("upload.html");
if($_FILES['file']['error']>0){
switch($_FILES['file']['error']){
case '1':
echo '文件过大';
break;
case '2':
echo '文件超出指定大小';
break;
case '3':
echo '只有部分文件被上传';
break;
case '4':
echo '文件没有被上传';
break;
case '6':
echo '找不到指定文件夹';
break;
case '7':
echo '文件写入失败';
break;
default:
echo '上传出错</br>';
}
}else{
if($_FILES['file']['size']>200000){
exit("文件超出指定大小");
}
//判断文件后缀名
$allowsuffix = array('png','jpg','jpeg');
$filename = explode('.',$_FILES['file']['name']);
$filesuffix = array_pop($filename);
if(!in_array($filesuffix,$allowsuffix)){
exit("文件后缀不正确");
}
$allowmine = array(
"image/png",
"image/jpg",
"image/jpeg",
"image/pjpeg",
"image/gif",
);
if(!in_array($_FILES['file']['name'],$allowmine)){
exit("文件格式不正确");
}
//指定上传文件路径
$path = "d:/phpstudy/PHPtutorial/www/upload/image/";
$newname = date('YmdHis').rand(0,9).'.'.$filesuffix;
$filepath = $path.$newname;
if(is_uploaded_file($_FILES['file']['tmp_name'])){
if(move_uploaded_file($_FILES['file']['tmp_name'],$filepath)){
echo "上传成功";
}else{
echo"上传失败";
}
}else{
echo"上传错误";
}
}
?>
数组最后一个多了个,
没听懂,报什么错呢?51行