Title: setting custom upload folder
Last modified: August 20, 2016

---

# setting custom upload folder

 *  [gavsiu](https://wordpress.org/support/users/gavsiu/)
 * (@gavsiu)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/setting-custom-upload-folder/)
 * I have a custom upload folder already set and upgraded WordPress to 3.5.1. I 
   was building my website and decided to finally upload some test images and realized
   that WordPress will create images in the defined directory, but is unable to 
   access it. Printing out the `wp_get_attachment_image_src` array shows it’s pointing
   to the correct path, but is returning a 404. When I try to delete the image through
   the media manager, it cannot physically delete the images.
 * WordPress is installed in the root directory and I set the uploads folder to 
   another folder in the root directory. I am using the Roots Theme which sets the
   upload directory to the root (which is also what I want) with functions.
 * When I change the upload folder back to default, the option to modify the setting
   disappeared, but newly uploaded images work.
 * It is my understanding that it was only the UI to modify the setting was removed
   from new versions of WordPress.
 * I tried to define the directory in wp-config and set the admin option to blank
   to remove the UI, but same thing. WordPress cannot display the images in the 
   admin panel or on the site because of 404 errors. It can, however, delete the
   files physically when I do it through media manager.

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

 *  [Chris Olbekson](https://wordpress.org/support/users/c3mdigital/)
 * (@c3mdigital)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/setting-custom-upload-folder/#post-3460575)
 * This will filter your upload directory and set it to site_root/assets
 *     ```
       add_filter( 'upload_dir', 'upload_dir_filter' );
   
       function upload_dir_filter( $upload ) {
       	$dir = $_SERVER['DOCUMENT_ROOT'];
       	$upload_dir = $dir['basedir'] . '/assets';
       	$upload_url = $dir['baseurl'] . '/assets';
   
       	wp_mkdir_p( $upload_dir );  //WordPress will check if the dir exists and can write to it.
       	$upload['path'] = $upload_dir;
       	$upload['url']  = $upload_url;
   
       		return $upload;
       	}
       ```
   
 *  Thread Starter [gavsiu](https://wordpress.org/support/users/gavsiu/)
 * (@gavsiu)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/setting-custom-upload-folder/#post-3460579)
 * Didn’t seem to do anything. The url WordPress spits out should work. I even double
   checked with an FTP explorer. `/assets/` is in the root and the images exist 
   as was created by WordPress.
 *  Thread Starter [gavsiu](https://wordpress.org/support/users/gavsiu/)
 * (@gavsiu)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/setting-custom-upload-folder/#post-3460609)
 * I believe this issue may be caused by not being able to write to parent directory.
 * I’m going to keep the upload folder as wp-content/uploads and use htaccess to
   redirect /assets/ to wp-content/uploads.
 * I’m just going to use this:
 *     ```
       function assets_path($fullpath) {
         $upload_dir = wp_upload_dir();
         $replaced_path = str_replace($upload_dir['baseurl'], '/assets', $fullpath);
         return $replaced_path;
       }
       ```
   
 * and add a rewrite for /assets/ to /wp-content/uploads/

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

The topic ‘setting custom upload folder’ is closed to new replies.

## Tags

 * [folder](https://wordpress.org/support/topic-tag/folder/)
 * [wp-config](https://wordpress.org/support/topic-tag/wp-config/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [gavsiu](https://wordpress.org/support/users/gavsiu/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/setting-custom-upload-folder/#post-3460609)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
