![](/img/trans.png)
[英]Forbidden You don't have permission to access this resource. Apache/2.4.46 (Win64) OpenSSL/1.1.1g PHP/7.2.34 Server at localhost Port 80
[英]You don't have permission to access this resource. Additionally, a 403 Forbidden error was encountered
我有一個基於核心 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);
}
}
?>
這是錯誤的圖像
這很可能是由您的 web 服務器或路徑/文件權限引起的。 例如,在 Linux 中,您的路徑對於用戶 www-data 或 web 服務器運行方式的任何人都是不可寫的。
在Apache web服務器中,配置文件或htaccess文件使目錄或文件不可讀、不可寫等。
為了解決您的問題,更需要提供系統和web服務器信息,例如:
希望這些信息有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.