【发布时间】: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"的标签,当点击它时,计算机的文件管理器会弹出供某人选择文件时选择文件,真正的输入文件=“类型”显示名称选择的文件 - 点击它旁边的提交按钮,用于将文件名发布到同一页,以便文件名显示在绿色大按钮旁边
【问题讨论】:
-
<p label for='file'><label for="file">- 错了,你为什么要在p中嵌套label?此外,p标签没有for属性。 -
<?php $val=$_POST['FORM']?> <?php echo $val?>- 您不需要为每个语句打开和关闭标签。 -
<input id="file" name="file" type="file" style="display:non;" name="FORM">有两个name属性。而display:non;有问题 -
呃...好吧,但这会影响它吗???