我在显示用户在我的模态弹出窗口中选择的文本文件的内容时遇到问题。
<input type="file" name="file">
<div id="myModal3" class="modal2">
<div id="modal-body2">
<div class="modal-content2">
<hr />
<div id="dvView" class="modal-header">
<b><font face="Arial" color="black" size = "2">Please notice that during upgrade, page will normally load for 5 minutes or more,</font><br></b>
<b><font face="Arial" color="black" size = "2">depending on the quantity of device to upgrade.</font><br></b>
<b><font face="Arial" color="black" size = "2">The page usually loads for 5 minutes per device. Kindly wait until results are posted.</font></b>
</div>
<hr />
<label for="chkContent2">
<input type="checkbox" id="chkContent2" onclick="ShowHideDiv1(this)" />
<b><font face="Arial" color="red" size = "2">View file content?</font></b>
</label>
<hr />
<div id="dvContent2" style="display: none">
<div class="modal-content3">
<?php
$filename = $_POST['file']
$fullPath = "E:\Data\\".$filename;
if (file_exists($fullPath)) {
if ($file = fopen($fullPath, "r")) {
while(!feof($file))
{
$line = fgets($file);
list($a, $b, $c, $d, $e ) = array_pad(explode(',', $line,5),5,null);
echo $a, "<br>", $b, "<br>", $c, "<br>", $d . "<br>". $e . "<br><br>";
}
fclose($file);
}
}
?>
</div>
</div>
<script type="text/javascript">
function ShowHideDiv1(chkContent2) {
var dvContent2 = document.getElementById("dvContent2");
dvContent2.style.display = chkContent2.checked ? "block" : "none";
}
</script>
</div>
</div>
</div>
这是我运行此代码时的输出。