谢谢你的提示。涉及 3 个 PHP 文件:
index.php - 有一个条目表单将值发布到work/data.php文件中,然后在其中操作的值保存在相应data_html文件夹中的新 HTML 文件中,然后由work/显示预览.php。在data.php中,有关于此代码:
<?php
// directory names
$dir_catalogues = '../catalogues/';
$dir_catalogue = $dir_catalogues.$_POST['catalogue_name'];
$dir_html = $dir_catalogue.'/data_html/';
$dir_csv = $dir_catalogue.'/data_csv/';
//Check if the directory with the name already exists
//Create our directory if it does not exist
if (!is_dir($dir_catalogues)) {
mkdir($dir_catalogues);
echo "Directory ".$dir_catalogues." created<br>";
}
if (!is_dir($dir_catalogue)) {
mkdir($dir_catalogue);
echo "Directory ".$dir_catalogue." created<br>";
}
if (!is_dir($dir_html)) {
mkdir($dir_html);
echo "Directory ".$dir_html." created<br>";
}
if (!is_dir($dir_csv)) {
mkdir($dir_csv);
echo "Directory ".$dir_csv." created";
}
// file names
$img_name_html = $_POST['img_name'].'.html';
$img_name_csv = $_POST['img_name'].'.csv';
$catalogue_name = 'catalogue-'.$_POST['catalogue_name'].'.html';
// HTML file content
$html = '
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Images rights information</title>
<style>
...
</style>
</head>
<body>
<div class="wrapper">
<table cellpadding="5">
<th colspan="2">Image info</th>
<tr class="thumb_row""><td class="logo" colspan="2"><img class="img_thumb" src="'.$_POST['img_use_url'].'" alt="Thumbnail"><h3>'.$_POST['img_title'].'</h3></td></tr>
<tr><td width="140" class="lab">File name</td><td colspan="5">'.$_POST['img_name'].'</td></tr>
<tr><td width="140" class="lab">Description</td><td colspan="5">'.$_POST['img_description'].'</td></tr>
<tr><td width="140" class="lab">Source URL</td><td colspan="5"><a href="'.$_POST['img_source_url'].'" target="_blank">'.$_POST['img_source_url'].'</a></td></tr>
<tr><td width="140" class="lab">Image use URL</td><td colspan="5"><a href="'.$_POST['img_use_url'].'" target="_blank">'.$_POST['img_use_url'].'</a></td></tr>
<tr><td width="140" class="lab">Copyright owner</td><td colspan="5">'.$_POST['img_copyright_owner'].'</td></tr>
<tr><td width="140" class="lab">Author</td><td colspan="5">'.$_POST['img_author'].'</td></tr>
<tr><td width="140" class="lab">Author\'s URL</td><td colspan="5"><a href="'.$_POST['img_author_url'].'" target="_blank">'.$_POST['img_author_url'].'</a></td></tr>
<tr><td width="140" class="lab">License</td><td colspan="5">'.$_POST['img_license'].'</td></tr>
<tr><td width="140" class="lab">License Nr.</td><td colspan="5">'.$_POST['img_license_nr'].'</td></tr>
</table>
</div>
</body>
</html>';
......
// create catalogue HTML file
file_put_contents($dir_catalogue .'/'.$catalogue_name, $html, FILE_APPEND | LOCK_EX);