i upload image in my plugin admin setting with :
i need this uploaded image to use in my plugin and to create the path for it , i follow :
it will generate the path with my image name as i gave it during upload time, but when i use it in my plugin, notching shows.
during use it in url , it gives me "Error code: filenotfound" .
may i know your suggestion ?
if its depend on permission and i need to show this image in public ,what i can do?
yup i read that and thank you for your reply , but the issue is, i know the name of the file and config data, my issue is generating path for it, lf you see my post here, i clearly mention what i did, but still can get the picture
no , "get_config " only gives configuration data which store in config plugin , in db, and only store name of the file.
for path , need to generate it in Moodle and i have issue with it
Thanks for your reply Mark,
it has same result of mine , i can get the path , but it gives error "Sorry, the requested file could not be found"
and even in image tag, cant show it.
is it any permission issu from moodleData folder?
as i know we store files in moodle data and make path in local plugin ?
Array ( [f95256e9a98dabad8a7a1a6e7f766f2cbe65bd20] => stored_file Object ( [fs:stored_file:private] => file_storage Object ( [tempdir:file_storage:private] => C:\xampp\htdocs\MOODLE\moodledata/temp/filestorage [filesystem:file_storage:private] => file_system_filedir Object ( [filedir:protected] => C:\xampp\htdocs\MOODLE\moodledata/filedir [trashdir:protected] => C:\xampp\htdocs\MOODLE\moodledata/trashdir [dirpermissions:protected] => 511 [filepermissions:protected] => 438 ) ) [file_record:stored_file:private] => stdClass Object ( [id] => 167 [contenthash] => ea852f03c19e4cddfa896582c960da33f15c6ebe [pathnamehash] => f95256e9a98dabad8a7a1a6e7f766f2cbe65bd20 [contextid] => 1 [component] => my_plugin [filearea] => my_area [itemid] => 0 [filepath] => / [filename] => gol.jpg [userid] => [filesize] => 152437 [mimetype] => image/jpeg [status] => 0 [source] => 1920x1080.jpg [author] => Hossein PS [license] => allrightsreserved [timecreated] => 1516368864 [timemodified] => 1516368867 [sortorder] => 0 [referencefileid] => [repositoryid] => [reference] => [referencelastsync] => ) [repository:stored_file:private] => [filesystem:stored_file:private] => file_system_filedir Object ( [filedir:protected] => C:\xampp\htdocs\MOODLE\moodledata/filedir [trashdir:protected] => C:\xampp\htdocs\MOODLE\moodledata/trashdir [dirpermissions:protected] => 511 [filepermissions:protected] => 438 ) ) )
Ah, I just realised what's probably wrong.
pluginfile.php doesn't serve the file for you - it calls my_plugin_pluginfile() from your plugin's lib.php file. You'll need to define this function - look at some existing plugins for examples.
In your case you probably just need to reconstruct the path from the function arguments, do $file = $fs->get_file_by_hash(sha1($path)); then send_stored_file($file);
Thanks for your reply Mark,
when i check different libs , i saw all using "send_stored_file" which internally use "send_file".
"send_file" make images headers to show it. but the issue is , in my plugin, i have many different images which i need to call (iv separate it by area) and i really didn't see in any libs call pluginfile() .
let say in template , moodle use "/theme/image.php/" to generate mage , is there any other image generator file like this which i pass path and get the images and print it out url in variable ?? (same as moodle template)
Dear Darko ,
thanks for your nice job.
I do it same in my block lib and setting files and call it instead of setting , in some classes of my own block . the issue is it generate the correct path and file name ,but unfortunately i receive "request file could not be found ".
ps. it generate bellow file :
<img src="http://localhost/MOODLE/moodle/pluginfile.php/1/my_plugin/my_area/0/apple.jpg" alt="This is my image!!!" />
Thanks Darko, i found the issue .
it was because of filearea , when i use many "configstoredfile" in same setting pages.
Hi Hossein , i have the same problem
can you explait better what is the solution.