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->getSize() and $file->getRealType() not working

Hello, I've found the following error, and looking for a solution I found this code on github for someone who is just like me. https://github.com/phalcon/cphalcon/issues/1931

Code:

foreach ($this->request->getUploadedFiles() as $file) {
var_dump($file, $file->getName(), $file->getTempName(), $file->getType(), $file->getSize(), $file->getRealType());
}

Results:

object(Phalcon\Http\Request\File)#82 (6) {
["_name":protected]=>
string(11) "suspect.gif"
["_tmp":protected]=>
string(14) "/tmp/phpUNwfs6"
["_size":protected]=>
int(0)
["_type":protected]=>
string(9) "image/gif"
["_error":protected]=>
int(0)
["_key":protected]=>
string(7) "files.2"
}
string(11) "suspect.gif"
string(14) "/tmp/phpUNwfs6"
string(9) "image/gif"
int(0)
NULL


2.7k

Hey, is a old post, but i had this problem recently and was solved just enabling fileinfo php extension. So, can be necessary to someone.