I’m using my own upload.php file to upload images to:
$upload_dir = wp_upload_dir();
$targetDir = $upload_dir['path'].'/';
It works like it should with this exception that images uploaded to uploads/2012/08/
don’t appear in Media Library
. Is there any function to “register” them there and in WP’s database?
It’s because you’re not registering them as a media type. Every upload is a WordPress post of the
attachment
type.To start, it would be something like this:
That should create an entry in your Media panel, and also convert the image to all the sizes you’re using in your theme.
A good option for you is to insert the above procedure in your
upload.php
. For that, you would need to include the WordPress required files too. Otherwise you would have to tell WordPress to run this somehow, maybe by a$_REQUEST
query or by a cron job.I think you should start digging in
media_handle_upload
function. It’s description in codex vague so try to understand it’s code.You can use this function to handle even uploads for you or you can grab some parts of it’s code to integrate in your own.