【发布时间】:2020-05-23 22:53:21
【问题描述】:
我有一个基于核心 PHP 构建的网站。它在 localhost 中运行良好。现在我上传到 public_html 文件夹中的主机中断服务器。当我尝试上传图片时出现错误“您无权访问此资源。此外,在尝试使用 ErrorDocument 处理请求时遇到 403 Forbidden 错误”。请帮助我。这没有给出特定的部分。所有可以选择上传图像的模块都会给出相同的错误。 表单前端代码
<form class="col-md-6" style="margin-left: 25%;background-color: #0D3349;color: white" action="addclientbackened.php" method="post" enctype="multipart/form-data">
<h1 style="text-align: center;color: white">Add images for Gallery</h1>
<br>
<br>
<hr>
<div class="form-group">
<label for="name">name</label>
<input type="text" class="form-control" id="name" placeholder="Enter Category name" name="name" required>
</div>
<hr>
<div class="form-group">
<label for="fpimage">Font Page image</label>
<input type="file" id="fpimage" name="fpimage" required>
<hr>
<input type="submit" class="btn btn-primary" name="save" value="save" style="font-size: 20px;margin-left: 42%">
<br>
</form>
支持的表单代码
<?php
include "db.php";
$fpimage= $_FILES['fpimage']['name'];
$check = getimagesize($_FILES["fpimage"]["tmp_name"]);
if ($check !== false) {
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
throw new Exception("file is not and image");
}
$target_dir = "client/";
$target_file = $target_dir . basename($_FILES["fpimage"]["name"]);
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
}
else {
move_uploaded_file($_FILES['fpimage']['tmp_name'], $target_dir . $fpimage);
$name = $_POST['name'];
$sql = "insert into hclients(name,image) values('".$name."','".$fpimage."')";
$result = mysqli_query($connn, $sql);
if ($result) {
// header('location:addclient.php');
echo '<script language="javascript">';
echo 'alert("Client stored successfuly")';
echo '</script>';
echo "<script> location='addclient.php' </script>";
} else {
echo mysqli_error($connn);
}
}
?>
这是错误的图像
【问题讨论】:
标签: javascript php