I am having one requirement to upload a file and store it in that module folder itself. I am just wondering how to do that. I have created a custom module with File type form element in that as below.
$form['BUCKAROO_CERTIFICATE'] = [ '#type' => 'managed_file', '#title' => $this->t('Certificate'), '#upload_validators' => [ 'file_validate_extensions' => array('pem'), ], '#description' => $this->t('Your Certificate (.pem file)').': '.\Drupal::state()->get('BUCKAROO_CERTIFICATE_NAME'), '#default_value' => $config->get('BUCKAROO_CERTIFICATE'), '#upload_location' => 'public://myfile/', ];
Here,I am giving
#upload_location as public://myfile. this is working fine by uploading a file in sites/default/files/myfile folder. How can I upload to a custom module folder. Please suggest some alternatives.