General developer forum

Creating a file from a /local/plugin.php

Picture of Abdul Bashet
Re: Creating a file from a /local/plugin.php

Hi Andrew Normore,

Have you solved this problem? Please provide me the exactly code to retrive the image. or how can I do <img src="image_path">

I found if just use the function send_stored_file($file, 0, 0, false); it is giving me the out put of file but not in moodle page.

Please help me.


Average of ratings: -
Picture of Jitendra Gaur
Re: Creating a file from a /local/plugin.php

Hi Abdul,

Use this code to show the image in img tag

$fullpath = "{$CFG->wwwroot}/pluginfile.php/{$file->get_contextid()}/local_yourpluginname/content/{$file->get_itemid()}/{$file->get_filename()}";
$url = "{$CFG->wwwroot}/pluginfile.php/{$file->get_contextid()}/local_yourpluginname/content/";
$filename = $file->get_filename();
$path = $url.$file->get_filepath().$file->get_itemid().'/'.$filename;
echo html_writer::tag('img','',array('src'=>$fullpath));

Average of ratings: -