I have a website that I built on core PHP.it works perfectly fine in localhost. Now I uploaded on host break server in the public_html folder. when I try to upload an image it gives an error "You don't have permission to access this resource. Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request".Please help me with this. This does not give on a specific section. All the modules which have an option to upload an image give the same error. front end code of form

<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>
            <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 class="form-group">
                <label for="fpimage">Font Page image</label>
                <input type="file" id="fpimage" name="fpimage" required>

            <input type="submit" class="btn btn-primary" name="save" value="save" style="font-size: 20px;margin-left: 42%">

backened code of form


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




Here is the image of error


It's most likely caused by your web server, or path/file permissions. For instance, in Linux, your path is not writable for user www-data or anyone the web server run-as.

In Apache web server, the configuration file or the htaccess file made the directory or file not readable, writable, etc.

To solve your problem, it's more required to provide the system and web server information, such as:

  • Operating System?
  • Web server?
  • Web server configuration?
  • Directory permissions

2020欧洲杯时间表Hope this information helps.

| improve this answer | |
  • I uploaded my website on the host break server. and I don't have .htaccess file – Fahad Munir May 24 at 12:39
  • You can try to write file to the same directory in PHP, such as using function file_put_contents($path,$content); to see if there is permission issue in PHP script to divide the problem. – tgarm May 25 at 3:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.