Good day. There is a problem: I am creating a plugin for WordPress. In the functionality of the plug-in there is a moment of uploading the file to the specified directory when editing the post and, accordingly, attaching the file to the post. Sample code (all inside the class):
add_action('save_post', array(&$this, 'savePostIcon')); function savePostIcon($id){ $opts = $this->getOptions(); //var_dump($_FILES); - пусто if(isset($_FILES['myplugin'])){ if(move_uploaded_file($_FILES['myplugin']['tmp_name'], $opts['path'].$_FILES['myplugin']['name'])){ add_post_meta($id, 'posticon_icon', $_FILES['myplugin']['name']); } } } The file is not sent through $ _FILES. And how then to fill it in the directory defined in the plugin settings?
Thank you in advance.
PS: enctype form is not worth it. What, in this case, can be done, except for inserting it into your javascript template to download the file?