哪位大师帮忙解决下,令我纠结了一上午的变量
时间:2011-09-20
来源:互联网
<?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换成任务一个字符结果都出不来了
作者: sb963023448 发布时间: 2011-09-20
<input type="file" ……
在 $_FILES 中接收数据
数组下表用''括起来更妥,另外依你的文件,上传后$_FILES['file']是个数组,,,调试可以var_dump打印判断
在 $_FILES 中接收数据
数组下表用''括起来更妥,另外依你的文件,上传后$_FILES['file']是个数组,,,调试可以var_dump打印判断
作者: amani11 发布时间: 2011-09-20
if($_POST[Submit]=="提交"){
==>
if(isset($_POST[Submit])){
还有确认你的环境支持段标记吗? 不支持的话用<?php echo $_SERVER['PHP_SELF'] ?>
其实为空就是提交到本页面了。
==>
if(isset($_POST[Submit])){
还有确认你的环境支持段标记吗? 不支持的话用<?php echo $_SERVER['PHP_SELF'] ?>
其实为空就是提交到本页面了。
作者: jordan102 发布时间: 2011-09-20
至少需将 if($_POST[Submit]=="提交"){
改为 if($_POST[Submit]=="上传"){
改为 if($_POST[Submit]=="上传"){
作者: xuzuning 发布时间: 2011-09-20
<form name="form1" method="post" action="<?=$_SERVER['PHP_SELF'] ?>" enctype="multipart/form-data">
加上这个
加上这个
作者: xing31120 发布时间: 2011-09-20
<form name="form1" method="post" action="<?=$_SERVER['PHP_SELF'] ?>"> 这个里面缺少了东西哦。。 应该是这样:
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
这样你的form提交后才有数据的。。。。。
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
这样你的form提交后才有数据的。。。。。
作者: TottyAndBaty 发布时间: 2011-09-20
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28