Title: Upload image into specific folder
Last modified: February 1, 2022

---

# Upload image into specific folder

 *  [gsosa2703](https://wordpress.org/support/users/gsosa2703/)
 * (@gsosa2703)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/upload-image-into-specific-folder/)
 * Hi everyone! I am uploading images to wordpress with the API using this endpoint:`/
   wp-json/wp/v2/media` but can I upload the image into a specific folder. For example`
   wp-content/uploads/myfolder`
 * Thanks for the help!!

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

 *  [kayart](https://wordpress.org/support/users/kayart/)
 * (@kayart)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/upload-image-into-specific-folder/#post-15317230)
 * You can create your own API endpoint to achieve this
 *  Thread Starter [gsosa2703](https://wordpress.org/support/users/gsosa2703/)
 * (@gsosa2703)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/upload-image-into-specific-folder/#post-15324036)
 * Hi thank u very much!
 * I have another question, i have this function
 *     ```
       function upload_photo(){
   
       	$desc = 'some description';
       	$file = 'url';
       	$file_array  = [ 'name' => wp_basename( $file ), 'tmp_name' => download_url( $file ) ];
   
       	// If error storing temporarily, return the error.
       	if ( is_wp_error( $file_array['tmp_name'] ) ) {
       		return $file_array['tmp_name'];
       	}
   
       	// Do the validation and storage stuff.
       	$id = media_handle_sideload( $file_array, 0, $desc );
   
       		// If error storing permanently, unlink.
       	if ( is_wp_error( $id ) ) {
       		@unlink( $file_array['tmp_name'] );
       		return $id;
       	}
   
       }
       ```
   
 * This function save an external url image inside wordpress and is working but 
   it is saving the image in uploads/year folder but i need save the photo in a 
   specific folder like, uploads/myfolder. How can i do it?
 * Thanks again

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

The topic ‘Upload image into specific folder’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [gsosa2703](https://wordpress.org/support/users/gsosa2703/)
 * Last activity: [4 years, 4 months ago](https://wordpress.org/support/topic/upload-image-into-specific-folder/#post-15324036)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
