Title: wp_insert_attachment
Last modified: August 19, 2016

---

# wp_insert_attachment

 *  [kmcadams](https://wordpress.org/support/users/kmcadams/)
 * (@kmcadams)
 * [15 years, 12 months ago](https://wordpress.org/support/topic/wp_insert_attachment/)
 * [http://codex.wordpress.org/Function_Reference/wp_insert_attachment](http://codex.wordpress.org/Function_Reference/wp_insert_attachment)
 * wp_insert_attachment( $attachment, $filename, 37 );
    this states that $filename
   is “Location of the file on the server. Use absolute path and not the URI of 
   the file. The file MUST be on the uploads directory.”
 * when i append the full physical path of this file relative to the server root
   and look at the image in the media library the file uri is incorrect.
 * when i use the path to the file from the uploads directory the uri is correct.
 * what is meant by this – is it the absolute path of the image file starting at
   the uploads directory?

The topic ‘wp_insert_attachment’ is closed to new replies.

## Tags

 * [attachment](https://wordpress.org/support/topic-tag/attachment/)
 * [media](https://wordpress.org/support/topic-tag/media/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * 0 replies
 * 1 participant
 * Last reply from: [kmcadams](https://wordpress.org/support/users/kmcadams/)
 * Last activity: [15 years, 12 months ago](https://wordpress.org/support/topic/wp_insert_attachment/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
