PHP文件上传错误
我用这个代码在WINDOWS上传文件成功,但到LINUX下失败了,请帮我看看什么原因,以下是代码:
————u1.htm————
<form enctype="multipart/form-data" name = "submitform" action="u1.php" method="post">
<input type="hidden" name="max_file_size" value="50000000">
<input type = "hidden" name = "uploadaction" value = "1">
upfile
<input name="userfile" type="file" size="30">
<input name="submit" value="submit" type="submit">
<input name="reset" value="replace" type="reset">
</form>
————u1.php————
<?
$uploadaction=0;
$timelimit=0;
set_time_limit($timelimit);
$uploaddir = '/root/file/';
$uploadfile = $uploaddir.$_FILES['userfile']['name'];
$tmpfile = $_FILES['userfile']['tmp_name'];
$file_size = $_FILES['userfile']['size'];
$errno = $_FILES['userfile']['error'];
echo "The uploadfile is $uploadfile";
echo "The tmpfile is $tmpfile";
if(!file_exists($uploadfile))
{
if(move_uploaded_file($tmpfile,$uploadfile))
{
echo "The file $uploadfile($strfilesize)upload successful!";
}
else
{
echo"The file$uploadfile upload failed(error code:$errno)";
}
}
set_time_limit(30);
?>
运行后错误是:upload failed(error code:0)
------解决方案--------------------你的程序没有问题,应当是php.ini配置文件的问题。
------解决方案--------------------chmod($uploaddir,"777")
文件权限.....
------解决方案--------------------$errno = $_FILES['userfile']['error'];
其值为 0,没有错误发生,文件上传成功。
你看下move_uploaded_file($tmpfile,$uploadfile)里面的参数路径是否正确,且有读写权限
------解决方案--------------------/tmp有空间吗?
selinux是否关掉?