我有一個PHP表單,其中創建了一個表中的服務器上的文件夾中的所有文件,並且創建的每一行都分配了一個複選框,用於決定哪些文件將被刪除或共享等。每行給出一個名稱checkbox[$rownumber]
來區分每個,然後當單擊一個按鈕,目前爲了確保我可以得到它的工作,它只是打印行被選中 - 但我不能得到這個加工。PHP從複選框中獲取選定的錶行
首先,與行從服務器表中創建的,這是代碼,它正確地創建它們,因爲我希望
<?php
if(isset($_REQUEST['deleteFile']))
{var_dump($_REQUEST);
if(isset($_POST['checkbox']))
{
print_r($_POST);
}
}
?>
<form name="mainHomescreen" action="MainHomescreen.php" method="POST">
<nav>
<input type="text" name="Search" value="Search" style = "color:#888;" onFocus="inputFocus(this)" onBlur="inputBlur(this)"/>
</nav>
<sidebar>
<input type="button" value="Create Folder" onClick="createFolder()"/>
<input type="button" value="Download Selected Files/Folders" onClick=" "/>
<input type="button" value="Encrypt Selected" onClick="encrypt()"/><br>
<input type="button" value="Share Selected" onClick="shareFolder()"/>
<!-- upload a file -->
<div id="fileUpload">
<div id="uploadPopup">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="uploadForm" method="post" name="uploadForm" enctype="multipart/form-data">
Select file to upload: <input name="fileUpload" type="file" /><br />
<input type="submit" value="Upload File" name="submitFile"/>
</form>
</div>
</div>
<input type="button" name="upload" value="Upload File" onClick="showUpload()"/>
<input type="submit" value="Delete" name="deleteFile"/>
<input type="button" value="Rename" onClick=" "/><br>
<input type="button" value="Password Protect Folder/ File" onClick=" "/><br><br>
</sidebar>
<article>
<span class="error"><?php echo $error;?></span>
<table id="detailView" style="width:100%">
<!-- php to create table -->
<?php
//open file names
$dir = opendir("/home/a1962403/public_html/files");
$filearray = array(array(array()));
echo '<table cellpadding="10" cellspacing="0" style="width:100%">';
echo '
<tr>
<th> </th>
<th>File</th>
<th>Date</th>
<th>Size</th>
</tr>
';
$rownumber = 0;
//List files in directory
while (($file = readdir($dir)) !== false)
{
//gets the file date, string needed decoding otherwise throws error.
$date = @filemtime($file);
$date = date("F d Y H:i:s.", filemtime(utf8_decode("/home/a1962403/public_html/files/$file")));
$size = filesize("/home/a1962403/public_html/files/$file") . ' bytes';
$rownumber = $rownumber + 1;
//prints a table row
echo '<tr class="bottomline">';
echo "<td><input type='checkbox' name='checkbox[$rownumber]' value='[$rownumber]' </td>";
echo "<td>$file</td>";
echo "<td>$date</td>";
echo "<td>$size</td>";
echo '</tr>';
}
echo '</table>';
closedir($dir);
?>
</article>
</form>
</body>
</html>
由此,我有一個提交按鈕被稱爲「DELETEFILE」,這正如我剛纔所說的那樣,我想要使用它,只是爲了確保它能夠正常工作而獲得所選內容,但實際上並沒有給我任何輸出,因此不勝感激。
'isset()'檢查後'var_dump($ _ REQUEST)'的輸出是什麼? – RST 2014-12-07 14:11:05
if(isset_REQUEST ['deleteFile']))它是數組(4){[「Search」] => string(6)「Search」[「fileUpload」] => string(0)「」[「deleteFile」] => string(6)「Delete」[「siteowner」] => string(1)「1」} – Navvy 2014-12-07 14:13:37
你能展示更多的代碼嗎?完整的「表格」。 – RST 2014-12-07 14:27:44