Is there a way to upload files to the theme directory I use the following code to upload images should be used in slideshow of the theme settings theme-settings.php:

for ($i = 0; $i &lt; 7; $i++){
      $form['best_responsive_settings']['slideshow']['slideimages'][] = array(
        '#type' =&gt; 'managed_file',
        '#title' =&gt; t('Image').' #'.$i,
        '#upload_location' =&gt; file_default_scheme() . '://theme/backgrounds/',
    '#default_value' =&gt; theme_get_setting('background_file'), 
    '#upload_validators' =&gt; array(
      'file_validate_extensions' =&gt; array('gif png jpg jpeg')),

      );
  }  


Those files are uploaded to: sites\default\files\theme\backgrounds I want to change the uploading location to sites\all\themes\best_responsive\images\backgrounds. How could I change '#upload_location' to do that?
It doesn't look like the file module places any restriction on the upload path, so in theory it should be as simple as:

'#upload_location' =&gt; DRUPAL_ROOT . '/' . drupal_get_path('theme', 'MYTHEME') . '/images/backgrounds';


However, having your theme folder writable by the web server would usually indicate that permissions are not set correctly. It would be a better idea to fix those, and save your images in the proper location (i.e. sites/default/files); see Securing file permissions and ownership for full details.