specific folder for "admin_setting_configstoredfile"

specific folder for "admin_setting_configstoredfile"

by Hossein Poursaeedi -
Number of replies: 4
hello,


im using "admin_setting_configstoredfile" to pick image from user , how  to store it in my plugin pix folder?


thanks

Average of ratings: -
In reply to Hossein Poursaeedi

Re: specific folder for "admin_setting_configstoredfile"

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You don't store files uploaded by a user in your plugin pix folder, the File API will store them in Moodle's dataroot.

By the looks of it, admin_setting_configstoredfile will store the full path the to file in the config setting you specify in the constructor, so you should be able to use that value to display or link to the image.


In reply to Mark Johnson

Re: specific folder for "admin_setting_configstoredfile"

by Hossein Poursaeedi -

thanks for your reply.

do you mean file area?

__construct($name, $visiblename, $description, $filearea, $itemid = 0, array $options = null)

but usually when i check some codes in moodle , its used a single name which is parts of themes .
you mean i can use path instead?

In reply to Hossein Poursaeedi

Re: specific folder for "admin_setting_configstoredfile"

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The $name argument for an admin_setting object is the config setting in which the value is stored.  If you pass 'myplugin/mysetting'  as the name, you'll be able to read the resulting value by doing get_config('myplugin', 'mysetting').  As far as I can tell by a brief look at the code in admin_setting_configstoredfile.php, this should contain the full path to the saved file.
In reply to Mark Johnson

Re: specific folder for "admin_setting_configstoredfile"

by Hossein Poursaeedi -

if you mean there is no way to change the directory from moodle data root
so do i need to fetch path like 

$OUTPUT->setting_file_url() ??

ill get error ,when using this.