We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

File upload problem

Hello, I tried upload my file but it $this->request->hasFiles() returns false. I tried to dump $_FILES but it returns array(0) { }. Please help me please. This is my code.

<?
if ($this->request->isPost()) {
            var_dump($_FILES);
            echo "Check if the user has uploaded files";
            //var_dump($this->request);
            $path = '';
            if ($this->request->hasFiles() == true) {
                echo "Print the real file names and sizes";
                foreach ($this->request->getUploadedFiles() as $file) {
                    $path = 'files/test/'.$file->getName();
                    $ext = pathinfo($file->getName(), PATHINFO_EXTENSION);
                    echo $path;
                    $file->moveTo($path);
                }
            }
}
?>


43.9k

Hi, code seems to be OK, so, double chek your form (is it defined as a POST method, as multipart ???)

your form how you defined it ? just check your form for more debugging