文件不是通过HTTP POST方式上传来的!! 老师给我看一下,弄了好久都没搞定
<?php
header("content-type:text/html;charset=utf-8");
//$_FILES
$filename = $_FILES['myFile']['name'];
$type = $_FILES['myFile']['type'];
$tmp_name = $_FILES['myFile']['tmp_name'];
$error = $_FILES['myFile']['error'];
$size = $_FILES['myFile']['size'];
//判断错误信息
if($error == UPLOAD_ERR_OK) {
$destination = "uploads/".$filename;
if(is_uploaded_file($tmp_name)) {
if(move_uploaded_file($tmp_name, $destination)) {
$mes = "文件上传成功!";
}else {
$mes = "文件移动失败!";
}
}else {
$mes = "文件不是通过HTTP POST方式上传上来的";
}
}else {
switch ($error){
case 1:
$mes = "超过了配置文件上传大小";
break;
case 2:
$mes = "超过了表单设置上传文件大小";
break;
case 3:
$mes = "文件部分被上传";
break;
case 4:
$mes = "没有文件上传";
break;
case 6:
$mes = "没有找到临时目录";
break;
case 7:
$mes = "文件不可写";
break;
case 8:
$mes = "由于PHP扩展程序中断了文件上传";
break;
}
}
echo $mes;