您无权访问此资源。此外,遇到403禁止错误

时间:2020-05-23 22:53:21

标签: javascript php

我有一个基于核心PHP构建的网站。它在localhost中可以正常运行。现在,我在public_html文件夹中的主机中断服务器上上传了。当我尝试上传图像时,出现错误“您无权访问此资源。此外,尝试使用ErrorDocument处理请求时遇到403禁止错误”。请帮助我。这没有在特定部分给出。所有可以上传图像的模块都给出相同的错误。 表格的前端代码

<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);

        }

    }


?>

这是错误的图片

1 个答案:

答案 0 :(得分:1)

最有可能是由您的Web服务器或路径/文件权限引起的。 例如,在Linux中,用户www-data或Web服务器运行身份的任何人都无法写入路径。

在Apache Web服务器中,配置文件或 htaccess 文件使目录或文件不可读,不可写等。

要解决您的问题,更需要提供系统和Web服务器信息,例如:

  • 操作系统?
  • Web服务器?
  • Web服务器配置?
  • 目录权限

希望此信息有所帮助。