-
-
Save hailwood/758fa432b040d0044e4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//... | |
//Upload the new file | |
$upload = new Upload(); | |
$upload->load($_FILES[$file['key']], "Form-Submissions/Form-One/{$sub->ID}"); | |
//Retrieve the File Object | |
$newFile = $upload->getFile(); | |
//We need to fetch the new file again otherwise things go wonky when we move the file... | |
/** @var File $newFileClass */ | |
$newFileClass = get_class($newFile); | |
/** @var File $newFile */ | |
$newFile = $newFileClass::get_by_id($newFileClass, $newFile->ID); | |
//Now we can move the new instance of the file | |
$newFile->setName($file['file'] . '.' . $newFile->getExtension()); | |
$newFile->Title = $file['title']; | |
$newFile->write(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment