I am currently developing a cron job that downloads a xml file from an external source and stores it within wordpress media. For debugging proposals, I have installed the plugin Advanced Cron Manager, which allows me to run cron jobs manually.
The manual execution of the cronjob works fine, without any problems. When the cronjob is executed by its schedule, I am facing: "Sorry, This File Type Is Not Permitted for Security Reasons".
Within my cron function, I have configured:
/** Allow all filetypes to be uploaded */ define('ALLOW_UNFILTERED_UPLOADS', true);
Since this did not work, I also tried adding
ALLOW_UNFILTERED_UPLOADS within my
wp-config.php, which ended up in the same result. Also adding it to
ALLOW_UNFILTERED_UPLOADS to wp-cron.php did not help.
During the execution, I also see the following notice:
[24-Nov-2021 08:54:14 UTC] PHP Notice Constant ALLOW_UNFILTERED_UPLOADS already defined in /var/www/virtual/wpwwwdev/html/wp-content/plugins/phantoms-wp/includes/cron.php on line 16
So the const is definitely set. Is there something else I have to set for the cron call?
The error is thrown by:
$file = [ 'uri' => 'https://vereine.football-verband.de/xmlspielplan.php5?Ausgabe=xml', 'description' => date('d.m.Y', time()) . ' - XML Spielplan', 'name' => 'xmlspielplan.xml', 'type' => 'xml', 'tmp_name' => download_url('https://vereine.football-verband.de/xmlspielplan.php5?Ausgabe=xml') ]; media_handle_sideload( $file, 0, $file['description'] );
Best regards, Sebastian