[function.move-uploaded-file]:无法打开流:无效的参数

时间:2014-02-28 16:06:53

标签: php file-upload

我尝试上传图片时收到这两条消息:

  

警告:   move_uploaded_file(/images/uploads/2014-02-28_17:39:37-Untitled-1.png)   [function.move-uploaded-file]:无法打开流:无效的参数   在第23行的D:\ AppServ \ www \ my \ addpost.php

     

警告:move_uploaded_file()[function.move-uploaded-file]:无法执行   将'C:\ Windows \ Temp \ php13A7.tmp'移动到   '/images/uploads/2014-02-28_17:39:37-Untitled-1.png'in   第23行的D:\ AppServ \ www \ my \ addpost.php

这是我的代码:

$name = date("Y-m-d_H:i:s").'-'.$_FILES['image']['name'];
$type = $_FILES['image']['type'];
$temp = $_FILES['image']['tmp_name'];
$uerror = $_FILES['image']['error'];

list($width, $height) = @getimagesize($_FILES['image']['tmp_name']);
$maxhight = 1;
$maxwidth = 1;
if ($error == 0) {
    if(($height > $maxhight) or ($width > $maxwidth)){
        move_uploaded_file($temp,"/images/uploads/".$name);
    }else{
       $error = "Just you can upload photos!!";
    }
}else {
    $error = "error while uploading : " . $uerror;
}

注意:

  

/图​​像/上传/

文件夹已存在

1 个答案:

答案 0 :(得分:3)

您在目录名称中使用:。尝试更改目录名称:

$name = date("Y-m-d_H:i:s").'-'.$_FILES['image']['name'];

进入这个:

$name = date("Y-m-d_H-i-s").'-'.$_FILES['image']['name'];