【问题标题】:removing draft file after saving permanently in moodle File API在moodle File API中永久保存后删除草稿文件
【发布时间】:2014-06-10 19:15:32
【问题描述】:

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

但草稿仍然存在。
保存后如何删除草稿?

【问题讨论】:

    标签: php file-upload moodle file-manager


    【解决方案1】:

    等待几天 - Moodle 的 cron 进程会在此之后自动清理草稿文件(延迟是为了确保您还没有打开并使用表单的副本)。

    请记住,草稿区域文件不会占用服务器上的额外存储空间,因为所有具有相同内容的文件只存储一次,“mdl_files”表中的多个条目都指向服务器上相同的物理位置硬盘。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-10
      • 2011-08-31
      • 1970-01-01
      • 2016-06-15
      相关资源
      最近更新 更多