//photoform.php
<html>
<body>
<form action="upload.php" name="phsub" method="post" enctype="multipart/form-data">
<?php
session_start();
$op=$_POST["opcnt"];
if ($op!="Select")
{
echo "<fieldset>";
echo "<legend> Open Category </legend>";
for ($i=1;$i<=$op;$i++)
{
echo "<input name='ofile$i' id='ofile$i' type='file'/>";
echo"<br>";
}
echo "</fieldset>";
}
?>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
上传.php
<?php
$empty = $post = array();
foreach ($_POST as $varname => $varvalue) {
if(empty($varvalue)) {
$empty[$varname] = $varvalue;
}
else {
$post[$varname] = $varvalue;
}
}
print "<pre>";
if (empty($empty)) {
print "None of the POSTed values are empty, posted:\n";
var_dump($post);
}
else {
print "We have " . count($empty) . " empty values\n";
print "Posted:\n";
var_dump($post);
print "Empty:\n";
var_dump($empty);
exit;
}
?>
问题:当我列出所有 $post 值时,我只得到静态的“提交”按钮。我可以根据条件查看所有生成的文件上传控件。但无法在upload.php 文件中获得控制权。您能否建议代码中是否有任何问题。我是 PHP 新手。提前感谢您的投入。
谢谢 - Abhik Banerjee