<?php
if($_POST[Submit]=="提交"){
$file=$_POST[file]; } //取得文件域的值,并保存在变量 file 中,在下面的代码中显示变量file的值
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>获取文件域的值-php教程-www.dushuwu.net</title>
<style type="text/css">
<!--
.style1 {font-size: 14px}
.style2 {font-size: 12px}
-->
</style>
</head>
<body>
<table width="300" border="1" cellpadding="0" cellspacing="0">
<tr align="center">
<td height="25" colspan="2"><span class="style1">获取文件域的值</span></td>
</tr>
<form name="form1" method="post" action="<?=$_SERVER['PHP_SELF'] ?>">
<tr>
<td width="95" align="center"><span class="style2">上传:</span></td>
<td width="200">
<input name="file" type="file" id="file" size="15" maxlength="80">
</td>
</tr>
<tr>
<td align="center" class="style2">输出上传的值:</td>
<td class="style2"><?php echo $file;?></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="上传"></td>
</tr>
</form>
</table>
</body>
</html>这里的变量$file换成任务一个字符结果都出不来了
if($_POST[Submit]=="提交"){
$file=$_POST[file]; } //取得文件域的值,并保存在变量 file 中,在下面的代码中显示变量file的值
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>获取文件域的值-php教程-www.dushuwu.net</title>
<style type="text/css">
<!--
.style1 {font-size: 14px}
.style2 {font-size: 12px}
-->
</style>
</head>
<body>
<table width="300" border="1" cellpadding="0" cellspacing="0">
<tr align="center">
<td height="25" colspan="2"><span class="style1">获取文件域的值</span></td>
</tr>
<form name="form1" method="post" action="<?=$_SERVER['PHP_SELF'] ?>">
<tr>
<td width="95" align="center"><span class="style2">上传:</span></td>
<td width="200">
<input name="file" type="file" id="file" size="15" maxlength="80">
</td>
</tr>
<tr>
<td align="center" class="style2">输出上传的值:</td>
<td class="style2"><?php echo $file;?></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="上传"></td>
</tr>
</form>
</table>
</body>
</html>这里的变量$file换成任务一个字符结果都出不来了
==>
if(isset($_POST[Submit])){还有确认你的环境支持段标记吗? 不支持的话用<?php echo $_SERVER['PHP_SELF'] ?>
其实为空就是提交到本页面了。
改为 if($_POST[Submit]=="上传"){
加上这个