Title: Changing upload folder using update_option
Last modified: August 19, 2016

---

# Changing upload folder using update_option

 *  [richarduk](https://wordpress.org/support/users/richarduk/)
 * (@richarduk)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/changing-upload-folder-using-update_option/)
 * I can change the ‘Full URL path to files’ (seen in Settings/Media) using the 
   following in functions.php, but although the path is correctly displayed in the
   Media page it doesn’t actually work:
 *     ```
       $path = get_bloginfo('template_directory');
       $path = $path . '/images';
       update_option (upload_url_path , $path );
       ```
   
 * The only way to change the upload folder and get it working is by using a relative
   path (seen on the same page ‘Store uploads in this folder’) by using `update_option(
   upload_path , $path );` in functions.php.
 * However, I know of no way to get the relative path accurately and consistently
   either using WP functions or PHP functions (e.g. if sites are set up on subdomains).
   There is a lot of messy regex and hacky code around but I don’t trust any of 
   it to be rock-solid.
 * Any idea why the full path doesn’t work in ‘Full URL path to files’, or how to
   accurately get the relative path e.g. to the theme directory?
 * For a theme I want to release.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Purab](https://wordpress.org/support/users/wordpressapi/)
 * (@wordpressapi)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/changing-upload-folder-using-update_option/#post-1830467)
 * the only issue with your code is concatenation of variable.
    use following code.
 *     ```
       $path = get_bloginfo('template_directory');
       $path = .$path . '/images';
       update_option (upload_url_path , $path );
       ```
   
 *  Thread Starter [richarduk](https://wordpress.org/support/users/richarduk/)
 * (@richarduk)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/changing-upload-folder-using-update_option/#post-1830539)
 * Thanks for trying, but the extra full stop you put in throws up a syntax error
   that crashes the page.
 * At issue is the fact that my code correctly enters the full file path that I 
   want into Settings / Media / ‘Full URL path to files’ but that this has no effect
   on changing the default upload folder, whilst on the other hand I can’t find 
   a foolproof way of entering a relative url into the input box above that (‘Store
   uploads in this folder’) which I know WILL change the default upload folder.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Changing upload folder using update_option’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [richarduk](https://wordpress.org/support/users/richarduk/)
 * Last activity: [15 years, 5 months ago](https://wordpress.org/support/topic/changing-upload-folder-using-update_option/#post-1830539)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
