基本上我的程序是从目录加载图像。然后每个图像都是一个评论框,一个复选框(检查用户想要替换它),然后是一个按钮,允许上传另一张图片来替换旧图片。
到目前为止,这是我的代码。
<?php
$folder = "images/";
$filetype = '*.*'; // will need to add extensions here
$files = glob($folder.$filetype); // load in files
$count = count($files); // count them
echo '<table>';
$imageCount = 0;
$checkArray = array();
$commentArray = array();
$imageArray = array();
var_dump($_POST);
echo $_POST['check'][0];
for ($i = 0; $i < $count; $i++) {
$fileName = substr($files[$i],strlen($folder),strpos($files[$i], '.')-strlen($folder));
//replace the file here if needed
if (isset($_POST['check'][$i])){
$num = $_POST['check'][$i];
if (isset())
}
echo '<div id = "container">';
echo '<tr><td>';
echo '<a name="'.$i.'"><img src="'.$files[$i].'" /></a>';
echo $fileName;
echo '<form action = "index.php" method = "POST" enctype = "multipart/form-data">';
echo '</br></br>Comments:';
echo '<input type = "text" name = "comments[]" value = "SUP" id = '.$i.'></input>';
echo '<input type = "checkbox" name = "check[]" value = '.$i.'>Replace?</input>';
echo '<input type = "file" name = "fileUpload[]" value = "Upload new image." id = '.$i.'';
echo '</form>';
echo '</tr></td>';
echo '</div>';
}
基本上我一直遇到问题。我能够找到哪些盒子被检查,但是$ _FILES只会存储各种没有ID的图像。这意味着我无法确定哪个图像与哪个框一起使用。