$_FILES系统函数;
$_FILES['myFile']['name']文件名称
$_FILES['myFile']['type']文件的类型,服务端进行限制
image/**
image/x-png
application/x-zip-compressed
$_FILES['myFile']['size']上传文件大小
$_FILES['myFile']['tmp_name']上传服务后保存临时文件名
$_FILES['myFile']['error']错误代码;
0成功1超过php.ini大小2超过MAX_FILE_SIZE选项指定的值
3只有部分上传 5上传文件大小为0
move_uploaded_file(临时文件,目标位置和文件名);
上传后移动文件到目标位置的函数
is_uploaded_file(MIME);
判断上传MIME类型的文件函数
复制代码 代码如下:
<form enctyoe="multipart/form-data" method="post" name="upload">
<input name="upfile" name="name">
</form>
if(is_uploaded_file($_FILES['myFile']['tmp_name'])){
$upfile = $_FILES['upload'];
$name = $upfile['name'];
$type = $upfile['type'];
$size = $upfile['size'];
$tmp_name = $upfile['tmp_name'];
$error = $upfile['error'];
switch($type){
case 'image/pjpeg' : $ok=1;
break
}
if($ok){
move_uploaded_file($tmp_name,'up/'.$name);
}else{
echo "文件类型不允许";
}
}