急啊!!!在线等!!!

Deckguan 2006-07-05 11:55:46
为什么我用POST方法不能得到FILE里的值啊?????????
例:
<body>
<form action="try.php" method="post" enctype="multipart/form-data" name="form1">
<table width="498" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#E9F2FF">
<tr class="ds">
<td><div align="right">杂志封面:</div></td>
<td colspan="2"><input name="face" type="file" id="face" size="30"></td>
</tr>
<tr class="ds">
<td align="right" valign="middle">上传杂志:</td>
<td colspan="2"><label>
<input name="zazhi" type="file" id="zazhi" size="30">
</label></td>
</tr>
<tr class="ds">
<td align="right" valign="top"><div align="center">
</div></td>
<td width="273" align="right" valign="top"><div align="center">
<input name="submit" type="submit" id="submit" value="上传">
<input type="reset" name="Submit" value="重置">
</div></td>
</tr>
</table>
</form>
</body>



在另一页面中用这样的方法
<?php
$face=$_POST['pic'];

$zazhi=$_POST['zazhi'];
echo $face;
echo $zazhi;
?>
请问为什么得不到这两个值啊????

...全文
194 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
van_glm 2006-07-06
  • 打赏
  • 举报
回复
检查一下路径,每一步执行后都echo 一下看看哪里值没传到
Deckguan 2006-07-06
  • 打赏
  • 举报
回复
下面是我的源程序大家看一下哦!!!为什么总是出现“填写内容不能为空!”
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>杂志上传</title>
<style type="text/css">
<!--
body {
background-image: url(image/9.gif);
}
.ds {
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
font-variant: normal;
color: #77A9E0;
text-decoration: none;
}
-->
</style></head>

<body>
<form action="upload_code.php" method="post" enctype="multipart/form-data" name="form1">
<table width="498" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#E9F2FF">
<tr class="ds" background="image/12.gif">
<td colspan="3"><div align="center">杂志上传</div></td>
</tr>
<tr class="ds">
<td width="101"><div align="right">杂志名称:</div></td>
<td colspan="2"><input name="name" type="text" id="name" size="50"></td>
</tr>
<tr class="ds">
<td><div align="right">杂志封面:</div></td>
<td colspan="2"><input name="face" type="file" id="face" size="30"></td>
</tr>
<tr class="ds">
<td align="right" valign="middle">上传杂志:</td>
<td colspan="2"><label>
<input name="zazhi" type="file" id="zazhi" size="30">
</label></td>
</tr>
<tr class="ds">
<td align="right" valign="top"><div align="right">杂志描述:</div>
<div align="left"></div></td>
<td colspan="2" align="left" valign="top"><textarea name="description" cols="50" rows="7" id="description"></textarea></td>
</tr>
<tr class="ds">
<td align="right" valign="top"><div align="center">
</div></td>
<td width="273" align="right" valign="top"><div align="center">
<input name="submit" type="submit" id="submit" value="上传">
<input type="reset" name="Submit" value="重置">
</div></td>
<td width="56" align="center" valign="middle"><a href="/radio/news/logout.php" class="ds">退出管理</a></td>
</tr>
</table>
</form>
</body>
</html>


另一个页面

<?php
/*$username=$_COOKIE['username'];
if(!$username)
{
echo'<script>alert("你还没有登陆!");</script>';
echo "<meta http-equiv=\"refresh\" content=\"2;url=index.php\">";
exit;
}
$username = $_COOKIE["username"];
$passwd = $_COOKIE["passwd"];
if(empty($username)||empty($passwd))
{
echo "<script language=\"javascript\">alert(\"请你先登陆。\");</script>";
echo "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">";
exit();
}*/
?>
<?php
$name=$_POST['name'];
$face=$_POST['pic'];
$zazhi=$_POST['zazhi'];
$description=$_POST['description'];
//echo $zazhi;exit;
/*$hot=$_POST['hot'];
$type=$_POST['type'];
$time=date("Y-m-d H:i:s");*/
$time1=date(Ymdhis);
//echo $message;exit;
if($name==""||$zazhi==""||$description=="")
{
echo'<script>alert("填写内容不能为空!");history.go(-1);</script>';exit;
}
$filename=$_FILES['face']['name'];
$filesize=$_FILES['face']['size'];
$filetype=$_FILES['face']['type'];
$zazhiname=$_FILES['zazhi']['name'];
$zazhisize=$_FILES['zazhi']['size'];
$zazhitype=$_FILES['zazhi']['type'];
//echo $filename."<br>".$filesize."<br>".$filetype;exit;
$face=explode(".",$filename);
$face_path="face/".$time1.".".$face[1];
$facepath="http://127.0.0.1/zazhi/".$face_path;
$zazhi=explode(".",$zaizhiname);
$zazhi_path="zazhi/".$time1.".".$zazhi[1];
$zazhipath="http://127.0.0.1/zazhi/".$zazhi_path;
//echo $true_pic_path;exit;
if(!copy($_FILES['face']['tmp_name'],$face_path))
{
$facepath="http://127.0.0.1/zazhi/face/noPic.jpg";
}
if(!copy($_FILES['zazhi']['tmp_name'],$zazhi_path))
{
echo "<script>alert('请选择你要上传的杂志!!');history.go(-1);</script>";
}
include"opendata.php";
$query = "INSERT INTO `zazhi` ( `id` , `name` , `zazhipath` , `facepath` , `description` )
VALUES (NULL , '$name', '$zazhipath', '$facepath', '$description')";
//$result = mysql_query($query);
if($result=mysql_query($query))
{
echo"<script>alert('你上传成功');</script>";
echo"<meta http-equiv=\"refresh\" content=\"0;URL=views.php\">" ;
//echo "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">";
}
else
{
echo'<script>alert("你上传失败,请重新上传!");history.go(-1);</script>';exit;
}
?>
请各位帮个忙啊!!急急!!
mynamesucks 2006-07-06
  • 打赏
  • 举报
回复
<?php
$face=$_FILE['pic'];

$zazhi=$_FILE['zazhi'];
echo $face;
echo $zazhi;
?>
zeroleonhart 2006-07-06
  • 打赏
  • 举报
回复
I haven't see any input named "pic" in your code.
and you are posting files,you should use up_load_file.
van_glm 2006-07-06
  • 打赏
  • 举报
回复
msn说吧.van_glm@hotmail.com
Deckguan 2006-07-06
  • 打赏
  • 举报
回复
为什么总是得不到$zazhi和$face这两个值啊!!!!!!!!!!!
Deckguan 2006-07-06
  • 打赏
  • 举报
回复
这个我知道啊!!!我就是问为什么总是得不到FILE
ttzhangzhiwei 2006-07-06
  • 打赏
  • 举报
回复
那是你的上传文件时没有成功也就是zazhi这个字段没有值
你用echo "$zazhi";
试试看
ttzhangzhiwei 2006-07-06
  • 打赏
  • 举报
回复
逐步检查

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧