3

私がmoodleにアップロードしたファイルへのURLを取得しようとしています。httpを使用してブラウザ経由でファイルにアクセスしたい。ファイルのパス名は、moodle データベースでハッシュ化されます。アップロードされたファイルの実際のURLをmoodleに取得する方法はありますか? これは、Moodle File API を使用して試していたコードです。

<?php
require_once("../config.php");
$course_name=$_GET["course"];
$table_files="files";
$results=$DB->get_records($table_files,array('filename'=>$course_name));
//Get the file details here::::
foreach($results as $obj){
        $contextid=$obj->contextid;
        $component=$obj->component;
        $filearea=$obj->filearea;
        $itemid=$obj->itemid;
}
$url=$CFG->wwwroot/pluginfile.php/$contextid/$component/$filearea/$itemid/$course_name;
echo print_r($url);

?>

助けていただければ幸いです。

4

1 に答える 1