Title: Handling Media Uploads in code
Last modified: August 19, 2016

---

# Handling Media Uploads in code

 *  [deeem119](https://wordpress.org/support/users/deeem119/)
 * (@deeem119)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/handling-media-uploads-in-code/)
 * Hello all.
 * I’m moving news items from a custom CMS into WordPress. In order to do it, I’ve
   been hacking the default rss-upload plugin to my needs.
 * I’ve added a section to it to extract the image links from the posts being read
   in, fetch the images from the old site and save them into WP using wp_upload_bits(),
   before modifying the link to point to the new location. All works well except
   for one point – is there any way of calling the full WordPress media upload routine
   so that the images get added to the Media Library? There are several hundred 
   of them, and many get reused regularly in posts, and will be called upon again.
 * I started trying to recreate this routine manually when I couldn’t find a way
   of doing it, but that path looks to be riddled with pitfalls, since media items
   are stored in the wp_posts table in the DB.
 * Thanks,

The topic ‘Handling Media Uploads in code’ is closed to new replies.

## Tags

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

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 0 replies
 * 1 participant
 * Last reply from: [deeem119](https://wordpress.org/support/users/deeem119/)
 * Last activity: [15 years, 5 months ago](https://wordpress.org/support/topic/handling-media-uploads-in-code/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
