Hi Nilesh,
Yes you are right. Moodle uses this url to show images. Try to use below script. I have used it to show files like pdf, word docs. May be it will help. Otherwise
we need to move your file at temporary location and then use this temporary location to show file.
$fileRecord = $DB->get_record("files", array("id" => $id));
$fs = get_file_storage();
// Prepare file record object
$fileFlag = false;
if($fileRecord) {
$fileinfo = array(
'component' => $fileRecord->component, // usually = table name
'filearea' => $fileRecord->filearea, // usually = table name
'itemid' => $fileRecord->itemid, // usually = ID of row in table
'contextid' => $fileRecord->contextid, // ID of
context 'filepath' => $fileRecord->filepath, // any path beginning and ending in /
'filename' => $fileRecord->filename // any filename
);
// Get file
$file = $fs->get_file($fileinfo['contextid'], $fileinfo['component'], $fileinfo['filearea'], $fileinfo['itemid'], $fileinfo['filepath'], $fileinfo['filename']);
if($file) {
$fileFlag = true;
}
}
// If file exists print file
if ($fileFlag) {
echo send_stored_file($file, 60*60);
} else {
// file doesn't exist - do something
send_file_not_found();
}