我正在尝试打开存储在本地存储中的文件。但是每次我单击“打开”时,都会出现此错误403。我认为这是在我尝试添加删除按钮并用我的php代码创建并发症时发生的。
请检查此代码:
<?php
$con=mysqli_connect("localhost","root","","annualdb");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM asean_japan WHERE agency='Rail'");
?>
<table class='page'>
<tr>
<th>Select</th>
<th>Agency</th>
<th>FileName</th>
<th>FileType</th>
<th>Date Received</th>
<th>Action</th>
</tr>
<?php
while($row = mysqli_fetch_array($result))
{
?>
<tr>
<td align='center' bgcolor='#FFFFFF'><input name='checkbox[]' type='checkbox' value='<?php echo $row['id']; ?>'></td>
<td><?php echo $row['agency']; ?></td>
<td><?php echo $row['filename']; ?></td>
<td><?php echo $row['filetype']; ?></td>
<td><?php echo $row['date']; ?></td>
<td><a target='_blank' href='../annual/indicators/" <?php echo $row['filename']; ?>"'>OPEN</a></td>
</tr>
<?php
}
?>
</table>
<?php
mysqli_close($con);
?>
答案 0 :(得分:0)
我尝试将表格放在php标记内,但突然起作用。这可能是什么问题?
echo "<table class='page'>
<tr>
<th>ID</th>
<th>Agency</th>
<th>FileName</th>
<th>FileType</th>
<th>Date Received</th>
<th>Action</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['agency'] . "</td>";
echo "<td>" . $row['filename'] . "</td>";
echo "<td>" . $row['filetype'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td><a target='_blank' href='../annual/CPA/" . $row['filename'] . "'>OPEN</a></td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
答案 1 :(得分:0)
<td><a target='_blank' href='../annual/indicators/" <?php echo $row['filename']; ?>"'>OPEN</a></td>
该行无效。它将创建如下链接: http://myhost.com/annual/indicators/%22%20somefile.pdf%22,其中%22是“的urlencoded值,%20是空白的urlencoded值。
您可以通过以下方式使用它:
<td><a target='_blank' href='../annual/indicators/<?php echo $row['filename']; ?>'>OPEN</a></td>