Uploading files - custom title and description
Permalink
I'm building a block which allows users to post a file to the site. The uploaded file is placed in the File manager. This part is working fine. My problem is how to update the files's title and description fields.
Here is a snip it from my controller.php
This works great, but here is where it all falls down.
In my foolish attempts to modify the file's title and description i found some code in properties.php (used by the File Manager):
Of course this crashes with the error "Fatal error: Call to undefined method FileSet::getVersionToModify()"
Any ideas?
Here is a snip it from my controller.php
Loader::library("file/importer"); $fi = new FileImporter(); $newFile = $fi->import($_FILES['my_file']['tmp_name'], $_FILES['my_file']['name']); // add file to file set Loader::model('file_set'); $fs = FileSet::createAndGetSet($my_set_name, FileSet::TYPE_PUBLIC, $uID = false); $fsf = $fs->addFileToSet($newFile);
This works great, but here is where it all falls down.
In my foolish attempts to modify the file's title and description i found some code in properties.php (used by the File Manager):
Loader::model("file_attributes"); $fv = $fs->getVersionToModify(); $fv->updateDescription($my_Description); $fv->updateTitle($my_Title);
Of course this crashes with the error "Fatal error: Call to undefined method FileSet::getVersionToModify()"
Any ideas?
The $newFile object is the one to update... not the $fs or $fsf. Thats what was throwing me off.