我有一个表单,提供特定类别,子类别和子子类别的信息,并执行以下操作;
我需要第2点和第3点的帮助,但这里有一些背景信息;
第2点:已经将表单上传到我需要的位置($ dir)但我需要它将数据插入到表格form_detail中;
MySQL表格;
表格详细信息 名称类型
代码:
<?php
require "config.php";
$cat = $_GET['cat1'];
//$catid = $_GET[''];
$subcat = $_GET['subcat'];
$subcatid = $_GET['subcatid'];
$subcat2 = $_GET['subcat2'];
//$subcat2id = $_GET[''];
///////// Getting the data from Mysql form//////////
$quer2="SELECT DISTINCT fileloc FROM subcategory2 where ";
///////////// End of query for first list box////////////
echo "The subcat ID is: " .$subcatid;
$predir = "./docs";
$dir = $predir."/" .$cat. "/" .$subcat."/" .$subcat2 . "/";
$dir= strtolower($dir);
$dir= str_replace(' ', '_', $dir);
//echo $dir;
$MyHtml1 = <<<EOD
<!doctype html>
<html>
<head>
<title>$subcat / $subcat2</title>
</head>
<body>
<table align="center" border="0" cellpadding="1" cellspacing="1" style="height: 100%; width: 100%;">
<tbody>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" style="height: 100%; width: 100%;">
<tbody>
<tr>
<td style="width: 50%;">
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
<tbody>
<tr>
<td style="width: 50%;">You are in the category:</td>
<td style="width: 50%;">$cat</td>
</tr>
<tr>
<td>You are in the subcategory:</td>
<td>$subcat</td>
</tr>
<tr>
<td>You are in section:</td>
<td>$subcat2</td>
</tr>
</tbody>
</table>
</td>
<td>
<p>Time:</p>
<p>Date:</p>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
<p>...</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>"
EOD;
echo $MyHtml1;
$pdfDirectory = $dir;
$thumbDirectory = $dir . "pdfimage/";
$filename = basename( $_FILES['pdf']['name'], ".pdf");
$filename = preg_replace("/[^A-Za-z0-9_-]/", "", $filename).".pdf";
$thumb = basename($filename, ".pdf");
if(move_uploaded_file($_FILES['pdf']['tmp_name'], $pdfDirectory.$filename)) {
//the path to the PDF file
$pdfWithPath = $pdfDirectory.$filename;
$pdfWithPathImage = $pdfDirectory."pdfimage/";
$pdfWithPathImageThumb = $pdfWithPathImage.$thumb.".jpg";
//add the desired extension to the thumbnail
$thumb = $thumb.".jpg";
//execute imageMagick's 'convert', setting the color space to RGB and size to 200px wide
//exec("convert \"{$pdfWithPath}[0]\" -colorspace RGB -geometry 100 $thumbDirectory$thumb");
exec("convert -density 200 -page 792x612 \"{$pdfWithPath}[0]\" -append -resize 450 -background white -flatten +repage $thumbDirectory$thumb");
//show the image
echo "<p><a href=\"$pdfWithPath\"><img src=".$pdfWithPathImageThumb." alt=\"\" /></a></p>";
echo $pdfWithPathImageThumb;
}
$MyHtml2 = <<<EOD
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="pdf" />
<input type="submit" name="submit" value="Upload" />
</form>
<table border="0" cellpadding="0" cellspacing="0" style="width: 937px;">
<tbody>
<tr>
<td colspan="2">
<p>Forms Available</p>
</td>
</tr>
</tbody>
</table>
<table border="1" cellpadding="0" cellspacing="0" style="height: 44px; width: 100%;">
<tbody>
<tr>
<td style="vertical-align: middle; width: 228px;">Ref</td>
<td rowspan="1" style="vertical-align: middle; width: 89px;">Cerfa</td>
<td colspan="3" rowspan="1" style="vertical-align: middle; width: 595px;">Name</td>
</tr>
<tr>
<td style="vertical-align: middle; width: 228px;"> </td>
<td rowspan="1" style="text-align: center; vertical-align: middle;"> </td>
<td colspan="3" rowspan="1" style="text-align: center; vertical-align: middle;"> </td>
</tr>
</tbody>
</table>
<p> </p>
</body>
</html>
EOD;
echo $MyHtml2;
?>
实现信息显示和存储的最佳方法是什么,在服务器端,我在subcat2(子子类别)中有创建,修改和删除的单独目录,我们可以进一步简化这个吗?
我打算尝试像插入表格form_detail那样......然后从那里开始,对我的代码提出任何建议,并在目录中创建一个表格表格?
哦,表格上传不检查位置或缩略图中已有的文件名(一个问题,但我稍后会解决它)。
如此复杂,但我想知道你们的大师是否可以帮我一把,任何建议都会受到热烈的欢迎和赞赏。