<?php
$fileInfo=$_FILES['myFile'];
$filename=$fileInfo['name'];
$type=$fileInfo['type'];
$tmp_name=$fileInfo['tmp_name'];
$size=$fileInfo['size'];
$error=$fileInfo['error'];
//判断下错误号,只有为0或者是UPLOAD_ERR_OK,没有错误发生,上传成功
if($error==UPLOAD_ERR_OK)
{
if(move_uploaded_file($tmp_name,"uploads/".$filename)){
echo '文件'.$filename.'上传成功';
}else{
echo '文件'.$filename.'上传失败';
}
}else{
//匹配错误信息
switch ($error) {
case 1:
echo '上传文件超过了PHP配置文件中upload_max_filesize选项的值';
break;
case 2:
echo '上传文件超过了表单MAX_FILE_SIZE限制的大小';
break;
case 3:
echo '文件部分被上传';
break;
case 4:
echo '没有找到上传文件';
break;
case 6:
echo '没有找到临时目录';
break;
case 7:
case 8:
echo '系统错误';
break;
}
}
Warning: move_uploaded_file(uploads/123.jpg): failed to open stream: No such file or directory in D:\xampp\htdocs\unload\doAction1.php on line 11
Warning: move_uploaded_file(): Unable to move 'D:\xampp\tmp\phpCCA.tmp' to 'uploads/123.jpg' in D:\xampp\htdocs\unload\doAction1.php on line 11
文件123.jpg上传失败
应该是没人建立uploads文件夹
uploads文件夹有吗?