I have a hard trouble uploading a file to server, more exactly function hasFiles() return false each time my code is:
protected function uploadForm() {
$form = new Form();
$form->add(new File("file", array()));
$form->add(new Text("name", array()));
return $form;
}
public function uploadAction() {
$this->view->form = $this->uploadForm();
}
public function savefileAction() {
$request = $this->request;
if ($request->isPost()) {
$this->flashSession->success('is post');
$name = $request->getPost('name');
$this->flashSession->success($name);
if ($request->hasFiles() == true) {
$this->flashSession->success('has files');
foreach ($request->getUploadedFiles() as $file) {
$this->flashSession->success($file->getName(), " ", $file->getSize());
$file->moveTo('/public/img/' . $file->getName());
}
}
}
}
template:
<?php echo Phalcon\Tag::form(array('admin/savefile',)); ?>
<?php echo $form->render("file"); ?>
<?php echo $form->render("name"); ?>
<?php echo Phalcon\Tag::submitButton(array("submit")) ?>
</form>
after submit the output s "is post" and "<name value>" so hasFiles() is always zero. please advice