问答详情
源自:2-1 PHP文件上传案例实战之错误信息详解

代码没错啊,为什么不对???

<?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上传失败

提问者:慕粉1115079975 2016-12-27 10:38

个回答

  • 慕粉4279450
    2017-05-24 18:54:34

    应该是没人建立uploads文件夹

  • 慕粉1707282033
    2017-01-02 21:24:05

    uploads文件夹有吗?