Title: wp_upload_bits &#8211; define subfolder before filename?
Last modified: August 22, 2016

---

# wp_upload_bits – define subfolder before filename?

 *  [tdoccc](https://wordpress.org/support/users/tdoccc/)
 * (@tdoccc)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/wp_upload_bits-define-subfolder-before-filename/)
 * Hi, I have this code for a plugin I’m using.
 * `$comment_image_file = wp_upload_bits( $title . $user->user_login . $comment_id.'.'.
   $file_ext, null, file_get_contents( $_FILES[ $comment_image_id ]['tmp_name'] ));`
 * So I can grab the postname ($title) and username ($user->user_login) as part 
   of the uploaded filename no problem.
 * However, I really want these variables to be defined as a subfolder before the
   filename… rather than as part of the filename string.
 * In wp_upload_bits it doesn’t seem possible. Is there a way to do it that I don’t
   know about… ?

The topic ‘wp_upload_bits – define subfolder before filename?’ is closed to new 
replies.

## Tags

 * [define](https://wordpress.org/support/topic-tag/define/)
 * [filename](https://wordpress.org/support/topic-tag/filename/)
 * [folder](https://wordpress.org/support/topic-tag/folder/)
 * [string](https://wordpress.org/support/topic-tag/string/)
 * [subfolder](https://wordpress.org/support/topic-tag/subfolder/)
 * [upload](https://wordpress.org/support/topic-tag/upload/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [tdoccc](https://wordpress.org/support/users/tdoccc/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/wp_upload_bits-define-subfolder-before-filename/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
