General developer forum

specific folder for "admin_setting_configstoredfile"

 
Picture of Hossein Poursaeedi
specific folder for "admin_setting_configstoredfile"
 
hello,


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


thanks

 
Average of ratings: -
Picture of Mark Johnson
Re: specific folder for "admin_setting_configstoredfile"
Core developersParticularly helpful MoodlersPlugin 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.


 
Average of ratings: -
Picture of Hossein Poursaeedi
Re: specific folder for "admin_setting_configstoredfile"
 

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?

 
Average of ratings: -
Picture of Mark Johnson
Re: specific folder for "admin_setting_configstoredfile"
Core developersParticularly helpful MoodlersPlugin 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.
 
Average of ratings: -
Picture of Hossein Poursaeedi
Re: specific folder for "admin_setting_configstoredfile"
 

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.
 
Average of ratings: -