PHP用COPY函数上传文件时总提示文件名不能为空
完整的提示是这样的:Warning:copy()[function.copy]:FilenamecannotbeemptyinC:\Apache2.2\htdocs\te...
完整的提示是这样的:
Warning: copy() [function.copy]: Filename cannot be empty in C:\Apache2.2\htdocs\test\8-16.php on line 21
文件上传失败!
后台代码:
<html>
<head>
<title>文件上传的后台处理页面</title>
</head>
<body>
<?php
if ($upfile == "none") {
echo "没有选择文件";
echo "<p>";
echo "点<a href=\"8-15.php\">这里</a>返回";
}
else {
$filepath = "images/"; //定义路径
$filename = $filepath.$upfile_name; //新的路径及文件名
echo $upfile_name; //显示文件名
echo "<p>";
echo $upfile_size; //显示文件大小
echo "<p>";
echo $upfile_type; //显示文件类型
if (copy($upfile, $filename)) { //复制文件的目标路径
unlink($upfile); //删除原有文件
echo "<p>";
echo "指定文件已经成功上传!";
echo "<p>";
echo "点<a href = \"8-15=\">这里</a>返回"; //给出返回链接
}
else {
echo "文件上传失败!";
}
}
?>
</body>
</html>
前台页面是这样的:
<html>
<head>
<title>文件上传的前台页面</title>
</head>
<body>
<form ENCTYPE = "multipart/form-data" ACTION = "8-16.php" METHOD = "POST" >
<input name = "upfile" type = "file" >
<p>
<input type = submit value = "确认提交" >
<input type = reset value = "重新选择" >
</form>
</body>
</html> 展开
Warning: copy() [function.copy]: Filename cannot be empty in C:\Apache2.2\htdocs\test\8-16.php on line 21
文件上传失败!
后台代码:
<html>
<head>
<title>文件上传的后台处理页面</title>
</head>
<body>
<?php
if ($upfile == "none") {
echo "没有选择文件";
echo "<p>";
echo "点<a href=\"8-15.php\">这里</a>返回";
}
else {
$filepath = "images/"; //定义路径
$filename = $filepath.$upfile_name; //新的路径及文件名
echo $upfile_name; //显示文件名
echo "<p>";
echo $upfile_size; //显示文件大小
echo "<p>";
echo $upfile_type; //显示文件类型
if (copy($upfile, $filename)) { //复制文件的目标路径
unlink($upfile); //删除原有文件
echo "<p>";
echo "指定文件已经成功上传!";
echo "<p>";
echo "点<a href = \"8-15=\">这里</a>返回"; //给出返回链接
}
else {
echo "文件上传失败!";
}
}
?>
</body>
</html>
前台页面是这样的:
<html>
<head>
<title>文件上传的前台页面</title>
</head>
<body>
<form ENCTYPE = "multipart/form-data" ACTION = "8-16.php" METHOD = "POST" >
<input name = "upfile" type = "file" >
<p>
<input type = submit value = "确认提交" >
<input type = reset value = "重新选择" >
</form>
</body>
</html> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询