Phalcon\Http\Request\File moveTo()

Hi, I try to use native method moveTo(). My version Phalcon last build 1.2.0 method moveTo() dont upload files. ```php foreach ($this->request->getUploadedFiles() as $key => $file) { $name = sha1($file->getName()[$key]) . '.' . pathinfo($file->getName()[$key], PATHINFOEXTENSION); $destination = $uploadDir.DIRECTORYSEPARATOR.$name; //this not work //$file->moveTo($destination); // this work correctly moveuploadedfile($file->getTempName()[$key], $destination); } ```



4.4k

else in documentation http://docs.phalconphp.com/en/1.1.0/api/Phalcon%5FHttp%5FRequest%5FFile.html public string getName () but it return array



85.0k

Currently that class does not support an array of files in the same index, that's why it's returning an array instead of a string



4.4k

Why moveTo () does not work? It is better not to use this class and work with the $ _FILES?



85.0k

This class is expecting a single file in the $_FILES superglobal if you pass an array of files the data would not be that it's expecting.

If you pass this it will not work ```php <input type="file" name="my%5Ffile[]"> <input type="file" name="my%5Ffile[]"> <input type="file" name="my%5Ffile[]"> ```

But if you pass this it works: ```php <input type="file" name="my%5Ffile1"> <input type="file" name="my%5Ffile2"> <input type="file" name="my%5Ffile3"> ```

Or you can create the Phalcon\Http\Request\File from the array of files:

foreach ($_FILES as $key => $uploadedFiles) {
    foreach ($uploadedFiles as $uploadedFile) {
        $file = Phalcon\Http\Request\File($uploadedFile);
    }
}


4.4k

ok thanks your solution works correctly.