我正在使用moodle filemanager
从用户那里获取文件并将其永久保存,如下所示:
$fs = get_file_storage();
$pluginname='profile_field_fileupload';
$pluginfolder= 'profile_field_profileimage';
$draftitemid=file_get_submitted_draft_itemid($this->inputname);
if (empty($entry->id)) {
$entry = new stdClass;
$entry->id = $this->userid;
}
$context = context_user::instance($this->userid);
$files = $fs->get_area_files($context->id, $pluginname,$pluginfolder,false,'',false);
foreach ($files as $file) {
$file->delete();
}
file_save_draft_area_files($draftitemid, $context->id, $pluginname,$pluginfolder,$entry->id,array('subdirs'=>false, 'maxfiles'=>1));
但草稿仍然存在。
保存后如何删除草稿?
最佳答案
等待几天 - Moodle 的 cron 进程会在此之后自动清理草稿文件(延迟是为了确保您还没有打开并使用表单的副本)。
请记住,草稿区域文件不会占用您服务器上的额外存储空间,因为具有相同内容的所有文件只存储一次,“mdl_files”表中的多个条目都指向服务器上相同的物理位置硬盘。
关于php - 在moodle File API中永久保存后删除草稿文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24149159/