【问题标题】:MY php form not working ie not sending data to my page我的 php 表单不起作用,即没有向我的页面发送数据
【发布时间】:2018-12-19 08:38:27
【问题描述】:

所以我有一个 php 表单(文件输入表单):

<?php $val=$_POST['FORM']?>

     element.style {
}

 button.punch {

border-top: 1px solid ;
border-right: 1px solid rgb(0,210,50);
border-bottom: 1px solid #151e33;
border-left: 1px solid #1f2d4d;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 10px 1px green, 0 1px 0 green, 0 6px 0 green, 0 8px 4px 1px green;
box-shadow: inset 0 1px 10px 1px green, 0 1px 0 green, 0 6px 0 green, 0 8px 4px 1px #111111;
color: #fff;
font: bold 20px/1 "helvetica neue", helvetica, arial, sans-serif;
margin-bottom: 10px;
padding: 10px 0 12px 0;
text-align: center;
text-shadow: 0 -1px 1px #1e2d4d;

-webkit-background-clip: padding-box;
}

<html>
<br><br><br>
<div style="text-align:center;box-shadow:2px 2px 2px 2px #999;padding-bottom:50%;margin-left:20%;margin-right:20%;">


<p label for='file'><label for="file"><button width="400%" style="width:100%;height:15%;background-color:rgb(0,255,128)" class="punch"><font size="13%" color="white"><label for="file">Choose file</label></font></button></label></p>
<br><br>

<div style="box-shadow:2px 2px 2px 2px #999;padding-bottom:70%;margin-left:5%;margin-right:5%;">
<br>
<?php $val=$_POST['FORM']?>
<?php echo $val?>
Public name

</div>
<form action="uploadtrying1.php" METHOD ="POST"><input id="file" name="file" type="file" style="display:non;" name="FORM"><input type="submit"></form>
</div>


</html>

应该发生的是,当用户单击绿色的“选择文件”大按钮并选择一个文件时,结果将发送到同一页面,并且 php 脚本会回显用户选择的文件。 .

但它不起作用

抱歉,代码有点混乱,让我解释一下:

  • 绿色的大按钮是input type="file"的标签,当点击它时,计算机的文件管理器会弹出供某人选择文件时选择文件,真正的输入文件=“类型”显示名称选择的文件
  • 点击它旁边的提交按钮,用于将文件名发布到同一页,以便文件名显示在绿色大按钮旁边

【问题讨论】:

  • &lt;p label for='file'&gt;&lt;label for="file"&gt; - 错了,你为什么要在p 中嵌套label?此外,p 标签没有for 属性。
  • &lt;?php $val=$_POST['FORM']?&gt; &lt;?php echo $val?&gt; - 您不需要为每个语句打开和关闭标签。
  • &lt;input id="file" name="file" type="file" style="display:non;" name="FORM"&gt; 有两个 name 属性。而display:non; 有问题
  • 呃...好吧,但这会影响它吗???
  • 我会读this,然后读this

标签: php html css forms


【解决方案1】:

在您的表单标签中使用上传文件。

 enctype="multipart/form-data"


<form action="uploadtrying1.php" METHOD ="POST" enctype="multipart/form-data">
<input id="file"   type="file"  name="FORM"><input type="submit"></form>

并通过 $_FILES 在您的 uploadtrying1.php 文件中获取您的文件。

【讨论】:

  • 那是一个的问题,而不是only的问题。您还应该扩展“为什么”。
  • 您是否删除了 name="file", 输入字段中的属性?
  • eM..no 当我尝试发布图片时,结果现在是“数组”
  • 其实告诉我你想做什么?
猜你喜欢
  • 2018-10-23
  • 2022-11-26
  • 2023-03-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-26
  • 2015-04-15
相关资源
最近更新 更多