move() uploaded file does not save the file
Notice: This thread is very old.
- richard
- Member | 60
I am stuck on this for a while. Why it dumps content of a file but nothing
gets uploaded into desired folder? No error.
I am on Xampp Windows, temp_files has full control rights for everyone…
Help is appreciated.
<?php
use Nette\Application\UI\Form;
class HomepagePresenter extends BasePresenter
{
public function formVerify(Form $form)
{
$file = $form['file']->value;
if($file->isOk()) {
$file->move('/temp_files');
var_dump($file->getContents());
}
}
protected function createComponentForm()
{
$form = new Form;
$form->addUpload('file', 'File: ');
$form->addSubmit('next', 'Next');
$form->onSuccess[] = callback($this, 'formVerify');
return $form;
}
}
?>
Last edited by richard (2011-08-10 13:01)
- rixi
- Member | 109
It's recommended to use wwwDir param for properly absolute paths in your application. For example if you load web application placed in subfolders, like //localhost/my_application/, etc ..
<?php
$file->move($this->context->params['wwwDir'] . '/temp_files/file.txt');
$file->move($this->context->expand('%wwwDir%/temp_files/file.txt')); // alternative
?>