Hi,
We are trying to use the filemanager to allow us to upload several files to a particular directory within our moodledata folder.
We've got it working in the standard way so far, so that it saves the records to the mdl_file table and presumably saves them somewhere in the moodledata/filedir directory, though I have no idea where, since it's all hashed file names and folders.
But we don't want to save them to those locations, we literally just want to upload the files we choose, to a particular folder within moodledata, with the same filenames as uploaded.
We can do this with a filepicker element:
class myform extends moodleform
{
public function definition()
{
$mform = $this->_form;
$mform->addElement('filepicker', 'myfile', 'My File');
$mform->addElement('submit', 'mysubmit', 'Upload');
}
}
$form = new myform();
if ($data = $form->get_data())
{
$filename = $form->get_new_filename('myfile');
$form->save_file('myfile', $CFG->dataroot . '/datauploads/current/' . $filename);
}
But can't seem to work out how to do it with filemanager. I'm trying:
$form->save_file('myfile', $CFG->dataroot . '/datauploads/current/');
Just passing the directory we want all the files to be saved to, but looking in the save_file method in formslib.php it's returning false because of the file_exists() call, because the directory exists, so it fails. So I have no idea how to tell it where to save the files.
The save_files() method seems to be deprecated, so we can't use that any more.
Is there a way to do this with the filemanager, or should we just write a custom php file upload instead?
Thanks.