LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 610|回复: 0

PHP上传文件出错问题!

[复制链接]
发表于 2005-4-14 12:25:50 | 显示全部楼层 |阅读模式
文件1:
<html>

<head>
<title>文件上传</title>

</head>

<body>


<table>
<form ENCTYPE="multipart/form-data" name="myform" action="upsave.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
<tr><td>选择上传文件</td><td><input name="myfile" type="file"></td></tr>
<tr><td><input name="submit" value="上传" type="submit"></td></tr>
</form>
</table>
</body>
</html>

文件2:upsave.php
<?php
$upload_file = $_FILES['upload_file']['tmp_name'];
$upload_file_name = $_FILES['upload_file']['name'];
if($upload_file)
{
$file_size_max = 1000*1000;
$store_dir = "/var/www/myweb/testRemote/upload/";
$accept_overwrite = 1;
if($upload_file_size>$file_size_max)
{
echo "对不起,你的文件容量超过大于规定";
exit;
}
if(file_exists($store_dir.$upload_file_name)&& !$accept_overwrite)
{
echo "存在相同的文件名的文件";
exit;
}
if(!copy($upload_file,$store_dir.$upload_file_name))
{
echo "复制文件失败.";
exit;
}
echo "<p>你上传了文件;";
echo $_FILES['upload_file']['name'];
echo "<br>";
echo "文件的MIME类型为:";
echo $_FILES['upload_file']['type'];
echo "<br>";
echo "上传文件大小";
echo $_FILES['upload_file']['size'];
echo "<br>";
echo "文件上传临时存储为:";
echo $_FILES['upload']['tmp_name'];
echo "<br>";
$Erroe = $_FILES['upload_file']['error'];
switch($Erroe)
{
case 0:
echo "上传成功";
break;
case 1:
echo "上传超时最大限制值";
break;
case 2:
echo "一样超过最大限制值";
break;
case 3:
echo "文件只有部分被上传";
break;
case 4:
echo "没有文件被上传";
break;
}
}
?>

错误:选中文件点上传总是提示“复制文件失败”这个信息。
请高手指点。另外请教用php上传文件和图片成功了的代码。谢谢!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表