Upload permission modx

62 Views Asked by At

I have a site on modx. I'm trying to implement uploading files from a website page to a server directory. I get a 403 Forbidden error when uploading. I already set the rights to the directory 777 755 but it did not help. I'm attaching the chunk and snippet code.

Text error: Forbidden

You don't have permission to access this resource.

I exposed the rights, but it did not help.

Snippet
<?php
if ($_FILES["fileToUpload"]["error"] == UPLOAD_ERR_OK) {
    $targetDir = "image/";
    $targetFile = $targetDir . basename($_FILES["fileToUpload"]["name"]);
    $uploadOk = 1;
    $imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION));

    if ($uploadOk == 1) {
        if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $targetFile)) {
            echo "Файл успешно загружен.";
        } else {
            echo "Произошла ошибка при загрузке файла.";
        }
    }
} else {
    echo "Произошла ошибка при загрузке файла.";
}

Chunk

<form class="uploadfile" action="[[!uploadFilePDF]]" method="POST" enctype="multipart/form-data">
  <input type="file" name="fileToUpload" id="fileToUpload">
  <input type="submit" value="Загрузить" name="submit">
</form>
1

There are 1 best solutions below

3
Anton Tarasov On
<form class="uploadfile" action="[[!uploadFilePDF]]"

What is inside action finally? This should be page URL(where your snippet should be executed) but not snippet call inself, is this something wrong here? Is this uploadFilePDF your snippet provided above?