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

Can NOT upload image in INVO template

Hello im using invo template to create a personal project. I create this folder manually -> projectname/public/img/ <- i need to upload images in that folder, i tryed everithing.

this is the form:

<?php 
echo $this->tag->form(array("admin/newPlace", "method" => "post", "enctype" => "multipart/form-data")); 
?>
<input class="form-control" id="picture" name="picture" type="file">
<button type="submit" class="btn btn-primary">Guardar</button>

in the controller:


class AdminController extends ControllerBase
{
public function newPlaceAction()
    {
    if ($this->request->hasFiles() == true) {
                    $baseLocation = 'img/';
                    foreach ($this->request->getUploadedFiles() as $file) {                     
                        $file->moveTo($baseLocation . $file->getName());
                    }
                }

but notting happends, please help me!!

Im using INVO template



85.5k

is there an error, blank page or someting ?

otherwise what does var_dump($this->request->getUploadedFiles()) sais.

i also use this library to help me upload files https://github.com/stanislav-web/phalcon-uploader

Check your permissions first. User that runs app server (i.e. PHP-FPM) must have write permission in your temp upload dir.