php - 将组合框中的文件加载到文本字段中
问题描述
我正在尝试将选定的文本文件从组合框中加载到文本框中。按下按钮时,我将文件内容的显示插入到文本框中,但文本框中没有显示任何内容。我不知道如何解决它。请帮忙,提前谢谢
<?php
$path = "books/";
$books = opendir($path);
while (($book = readdir($books)) !== false)
{
if(substr($book, -4) === ".txt") {
$filePath = $path.$book;
echo $filePath;
$theList .= '<option><a href="'.$filePath.'">'.$filePath.'</a>';
$openFile = fopen($filePath, "r") or die("Permission error");
$readBook = file_get_contents($filePath);
echo $readBook;
echo "<br>";
fclose($openFile);
}
}
closedir();
?>
<html>
<head>
<title>Books Form</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="jquery-3.6.0.js"></script>
<style>
</style>
</head>
<body>
<form method="POST" action="" id="bookform">
<label for="books"></label>
<select name="book" id="books" form="bookform">
<option value=""><?=$theList?></option>
</select><br><br>
<button style="position: relative; left: 240px" name="onClick" class="click" type="submit" form="form" value="">Wczytaj</button><br><br>
</form>
<div>
<textarea name="info" class="form-test" rows="30" cols="100">
<?php
if(isset($_POST['onClick']))
{
$readBook = file_get_contents($filePath);
echo $readBook;
//print_r($readBook);
}
?>
</textarea><br>
</div>
<form>
<button type="submit" form="form" value="Submit">Zapisz</button><br>
</form>
</body>
</html>
解决方案
推荐阅读
- vue.js - Menu Items being stacked Horizontally instead of Vertically when binding Items with v-for in Bootstrap Navbar
- c++ - c++ function pointer assignment is safe?
- dynamics-crm - ParentId in CustomerAddress Entity in Dynamics 365
- ubuntu - 使用 RAW 图像流式传输 raspicam_node
- r - 尝试根据列中的值生成一个分离数据帧的函数,然后从分离的数据中生成新的数据帧
- javascript - 我们应该关心 JS 非原始值的可变性吗?
- swift - SwiftUI navigationLink error - not accepting parameter on linked view
- ios - 未加载库:@rpath/FBSDKCoreKit_Basics.framework/FBSDKCoreKit_Basics
- python - 如何使用美汤查找功能提取html元素
- xml - MS Access VBA XML POST 使用 HTTP 使用 msxml2.DOMDocument.6.0