<?php
header('Content-Type:text/html;charset=utf-8');if ($_POST) {
$file = $_FILES['userfile'];
$dest_dir = 'Uploads';
$dest = $dest_dir.time().$file['name'];
if (! $file) {
echo '移动文件出错!';
exit;
} else {
$r = move_uploaded_file($file['tmp_name'], $dest);
echo '恭喜';
}
}
?><html>
<head>
</head>
<body>
<form action="test3.php" method="post" enctype="multipart/form-data" name="upform">
文件上传:<input type="file" name="userfile" />
<input type="hidden" name="max_file_size" value="100000" />
<input type="submit" value="上传" />
</form>
</body>
</html>上传后却显示:
Warning: move_uploaded_file(): The second argument to copy() function cannot be a directory in /usr/local/apache/htdocs/mytest/test3.php on line 28Warning: move_uploaded_file(): Unable to move '/tmp/phptVKLPP' to 'Uploads' in /usr/local/apache/htdocs/mytest/test3.php on line 28
怎么会这样?我的环境是centos

解决方案 »

  1.   

    chmod(dirname(__FILE__) . '/../folder', 0777);
      

  2.   

    这不是权限问题!
    Warning: move_uploaded_file(): The second argument to copy() function cannot be a directory
    是说 move_uploaded_file 函数的第二个参数不能是一个目录!
    另外
        $dest_dir = 'Uploads';
        $dest = $dest_dir.time().$file['name'];
    是错误的,至少需要
        $dest_dir = 'Uploads';
        $dest = $dest_dir.'/'.time().$file['name'];