*<?php $app->post('/uploadAction', function ( ) use ( $app ) {
function uploadAction()
{
if ($this->request->hasFiles() == true) {
$baseLocation = 'files/';
foreach ($this->request->getUploadedFiles() as $file) {
$photos = new Photo();
$photos->name = $file->getName();
$photos->size = $file->getSize();
$photos->save();
$file->moveTo($baseLocation . $file->getName());
}
}
}
}); ?>
<form action="uploadAction" method="POST" enctype="multipart/form-data"> <label>File</label> <input type="file" name="upFile"> <input type="submit" name="upload"> </form>*
I want to upload the file to files directory but it's not working. Please help me