php - 在moodle File API中永久保存后删除草稿文件

标签 php file-upload moodle file-manager

我正在使用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/

相关文章:

android - android 网络浏览器是否允许上传刚从相机拍摄的照片?

mysql - Moodle 1.9 REPLACE 破坏 utf8_unicode_ci 字符串

php - 无法使用wamp修改数据库中的数据

php - Laravel - 路由到 "views"内的文件夹

file-upload - Sitecore 上传文件观察器

javascript - kcfinder 的问题通过拖放创建多个图像

proxy - 带有反向代理的 Moodle 3.5

mysql - Moodle安装过程中出现错误 'Status Check'

php postgreSQL 错误

php - 正确使用 updateOrCreate 方法