uploading files

How i can upload files to the server???

in the documentation comes: ```php public function uploadAction() { // Check if the user has uploaded files if ($this->request->hasFiles() == true) { // 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
} ```


but $file->moveTo() throws me the error

```php<b>Warning</b>: moveuploadedfile(): The second argument to copy() function cannot be a directory in <b>/var/www/html/phalcon/apps/Inteligob/Controllers/BlobsController.php</b> on line <b>59</b><br /> <br /> <b>Warning</b>: moveuploadedfile(): Unable to move '/tmp/phpeK80pt' to 'upload/' in <b>/var/www/html/phalcon/apps/Inteligob/Controllers/BlobsController.php</b> on line <b>59</b><br />```


Normally PHP sends the mime type in the 'type' index of every file in $_FILES, however that index could be easily changed by an attacker to cheat an application:


You can better use the fileinfo (http://php.net/manual/en/function.finfo-open.php) function to get the right mime type once the file is uploaded:

public function uploadAction()
    if ($this->request->hasFiles() == true) {           
        $fi = new finfo(FILEINFO_MIME, '/usr/share/misc/file/magic');
        foreach ($this->request->getUploadedFiles() as $file) {
            echo 'Mime = ', $file->file($file->getTempName()), '<br>';                 


thanks, i resolved that with the fileinfo function, but now i have another problem, in fact i change the post, can you help me ??


It must be:

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