We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

$request->hasFiles() not detecting file upload

I am attempting to check to see whether the user of my application has uploaded a file upon registration. I have set the form enctype to multipart in my form:

<form class="col-md-3" action="create" method="POST" enctype="multipart/form-data">

In the CreateController I am doing the following, just to test the $request->hasFiles() method. I have placed this at the head of the method.

if($this->request->hasFiles()) {
        print 'File uploaded';

It's never true, even if a file is uploaded. I have also tried to var_dump($_FILES) and there seems to be nothing there too.

Any ideas what could be going wrong here?

When post_max_size is exceeded ' $_POSTand$_FILES` are empty on Apache not on Nginx, what I do:

if ($this->request->hasFiles()) {
else {
    if ((! empty ($_FILES) && $_SERVER['CONTENT_LENGTH'] > 0) ||
        (empty ($_POST) && empty ($_FILES) && $_SERVER['CONTENT_LENGTH'] > 0)) {
        // Clear errors
        while (ob_get_level() > 0) {

            'Uploaded file exceeds the maximum upload size allowed {0}',
    else {
        $this->appendMessage(__('No files uploaded'));

That was the problem :) Thank you sir.