![]() |
#2
cnenc2010-05-09 23:18
|

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. xmlns="http://www. http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP文件上传</title>
<script type="text/javascript">
function checkForm()
{
if (form1.userfile.value="")
{
alert("请选择要上传的文件。");
form1.userfile.focus();
return false;
}
}
</script>
</head>
<body>
<?php
if (!isset($_POST['submit'])){?>
<form name="fomr1" action="#" method="post" enctype="multipart/form-data" onsubmit="return checkForm()">
<table width="396" height="108" border="1" cellpadding="0" cellspacing="0" rules="none">
<tr>
<td colspan="2" bgcolor="#999999">文件上传</td>
</tr>
<tr>
<td width="97">选择文件:</td>
<td width="319"><input name="userfile" type="file" id="userfile" /></td>
</tr>
<tr>
<td><input name="MAX_FILE_SIZE" type="hidden" value="5242880" /></td>
<td><input type="submit" name="submit" value="执行文件上传" /> <input type="reset" name="reset" value="重置" /></td>
</tr>
</table>
<?php }else {
$uploaddir="../uploads/";
if (!file_exists($uploaddir)) mkdir($uploaddir);
$uploadfile=$uploaddir.basename($_FILES["userfile"]["name"]);
if (move_uploaded_file($_FILES["userfile"]["tmp_name"],$uploadfile))
{
printf("<b>上传文件信息</b>\n");
printf("<ul>");
printf("<li>文件名: %S</li>\n",$_FILES["userfile"]["name"]);
printf("<li>文件类型: %S</li>\n",$_FILES["userfile"]["type"]);
printf("<li>文件大小: %S</li>\n",$_FILES["userfile"]["size"]);
printf("<li>文件名: %S</li>\n",$_FILES["userfile"]["name"]);
printf("<p>文件上传成功</p>\n");
printf("<a href=\"%s\">返回</a>\n",basename($PHP_SELF));
}
else
{
printf("<p>文件未能上传成功</p>");
}
?>
</body>
</html>
错误提示:Parse error: syntax error, unexpected $end in F:\AppServ\www\MyServer\chap03.php on line 62<title>PHP文件上传</title>
<script type="text/javascript">
function checkForm()
{
if (form1.userfile.value="")
{
alert("请选择要上传的文件。");
form1.userfile.focus();
return false;
}
}
</script>
</head>
<body>
<?php
if (!isset($_POST['submit'])){?>
<form name="fomr1" action="#" method="post" enctype="multipart/form-data" onsubmit="return checkForm()">
<table width="396" height="108" border="1" cellpadding="0" cellspacing="0" rules="none">
<tr>
<td colspan="2" bgcolor="#999999">文件上传</td>
</tr>
<tr>
<td width="97">选择文件:</td>
<td width="319"><input name="userfile" type="file" id="userfile" /></td>
</tr>
<tr>
<td><input name="MAX_FILE_SIZE" type="hidden" value="5242880" /></td>
<td><input type="submit" name="submit" value="执行文件上传" /> <input type="reset" name="reset" value="重置" /></td>
</tr>
</table>
<?php }else {
$uploaddir="../uploads/";
if (!file_exists($uploaddir)) mkdir($uploaddir);
$uploadfile=$uploaddir.basename($_FILES["userfile"]["name"]);
if (move_uploaded_file($_FILES["userfile"]["tmp_name"],$uploadfile))
{
printf("<b>上传文件信息</b>\n");
printf("<ul>");
printf("<li>文件名: %S</li>\n",$_FILES["userfile"]["name"]);
printf("<li>文件类型: %S</li>\n",$_FILES["userfile"]["type"]);
printf("<li>文件大小: %S</li>\n",$_FILES["userfile"]["size"]);
printf("<li>文件名: %S</li>\n",$_FILES["userfile"]["name"]);
printf("<p>文件上传成功</p>\n");
printf("<a href=\"%s\">返回</a>\n",basename($PHP_SELF));
}
else
{
printf("<p>文件未能上传成功</p>");
}
?>
</body>
</html>
怎么改呢?在线等待师傅教我