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

upload file moveTo not copying a file

public function profilePictureAction()
{
    // Check if the user has uploaded files
    if ($this->request->hasFiles()) {

        // Print the real file names and sizes
        foreach ($this->request->getUploadedFiles() as $file) {

            // Print file details
            echo $file->getName(), " ", $file->getSize(), "\n";

            // Move the file into the application
            $file->moveTo('files/' . $file->getName());

        }
    }
}

this is my code I upload file using postman with form type: form-data and with image png. In my app directory I already create directory named files after projectname and in one directory with app, public folder. Why this happen? I expecting file copied after I send image data.



79.0k
Accepted
answer

Do you have some errors, somewhere? This issue is due to bad permissions 99%.



2.1k

I already chmod 755 files folder and chown :www-data and chown my-username no error its output is icon-testing.png 6773 image name and image size but not uploaded to files folder in my app.. how to solve bad permissions? Thank you..

Do you have some errors, somewhere? This issue is due to bad permissions 99%.



2.1k

change other access: create and delete files



13.8k

I looked for this issue for a while aswell, so for anyone searching for this problem and that doesnt have read write execute issues, ifound the answer here: https://forum.phalcon.io/discussion/1947/phalcon-don-t-recognize-html5-multiple-file-upload

For me it was the missing enctype in the form

{{ form('post/add', 'method': 'post', 'enctype': "multipart/form-data",'class':'form-post') }}