How to get an uploaded file directly

$this->request->getUploadedFiles() return an array of all uploaded file. Is there any clean way to access an uploaded file using its field name. It seems there is not method similar to: $this->request->getUploadedFile('avatar');



19.6k

As you say, it returns an array ( https://github.com/phalcon/cphalcon/blob/2.0.0/phalcon/http/request.zep#L759 ): the problem is that is an array of Files ( http://docs.phalconphp.com/es/latest/api/Phalcon%5Http%5Request%5File.html ). So, unless it is changed, you should create your own function that searchs for the specific file.



13.3k

Finally I used the following to access a single file: $file=new Phalcon\Http\Request\File($_FILES[$fieldName]); IMHO $this->request->hasFile($fileName) and $this->request->getFile($fileNmae) should be added to Phalcon\Http\Request.