A
A
Anatoly2021-06-15 12:21:09
PHP
Anatoly, 2021-06-15 12:21:09

How to check what error is in $_FILES?

How to display a message about what error occurred, if for example:
post_max_size = 2M
and I send via post 4M, then I get 500 (Internal Server Error) in the console.

echo $_FILES[];
in console reports: undefined

echo $_FILES["images"]["error"];
does not report anything

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vamp, 2021-06-16
@Tolly

According to the official documentation , post_max_size exceedance can only be tracked by adding a get parameter to the form:
<form action="edit.php?processed=1">

if (!empty($_GET['processed']) && empty($_POST) && empty($_FILES)) {
    echo 'Ошибка! Вы загрузили слишком большой файл';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question