Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

how to know the error in $file->moveTo()

Hi all,

I'm trying to upload images to my project Phalcon with Dropzone 4.2.0, but all data captured while trying to $ file-> moveTo () I get an error but not what is.

FileController - uploadAction

    public function uploadAction () {
    //elimina renderizado al ser un ajax
    $this->view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_NO_RENDER);

    //comprueba si hay archivos por subir
    if ($this->request->hasFiles() == true) {
        // Print the real file names and sizes
        foreach ($this->request->getUploadedFiles() as $file) {
            echo $file->getName(), " ", $file->getSize(), "\n";

            $fileObj       = new Files();
            $fileObj->name = $file->getName();
            $fileObj->size = round(($file->getSize()/1024),2);
            $fileObj->type = Files::IMG;
            $fileObj->of   = "Homes";
            $fileObj->ofId = $this->request->getPost('ofId');

            $fileObj->save();

            $file->moveTo('img/' . $file->getName());

            echo "<br>" ;
            echo $file->getError();
        }
    }

}

Notes:

  • $file->getError() give me 1
  • img folder in public is 777

How I can know that errors occur?

Thanks for the help :)



3.3k

Can anyone help me?



45.7k
Accepted
answer

Hey

You try dump at the line code

            $file->moveTo('img/' . $file->getName());
            die();


3.3k

I do not know the causes, but restarting the server manages.

Thanks @Thien