I have a front end uploader for members only, utilizing this code:
<?php
function insert_attachment_form($postID) {
?>
<form id="file-form" name="file-form" method="POST" action="" enctype="multipart/form-data" >
<input type="file" id="async-upload" name="async-upload" />
<input type="hidden" name="postID" value="<?php echo $postID; ?>" />
<?php wp_nonce_field('client-file-upload', 'client-file-upload'); ?>
<input type="submit" value="Upload" id="submit" name="submit" />
</form>
<?php }
function process_attachment() {
// verify this came from the our screen and with proper authorization,
// because save_post can be triggered at other times
if ( !wp_verify_nonce( $_POST['client-file-upload'], 'client-file-upload') ) {
return $post->ID;
}
// Is the user allowed to edit the post or page?
if ( !current_user_can( 'publish_posts', $post->ID ))
return $post->ID;
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_FILES )) {
require_once(ABSPATH . 'wp-admin/includes/admin.php');
$id = media_handle_upload('async-upload', $_POST['postID']);
unset($_FILES);
}
}?>
Ideally I would like to have the drag-and-drop WordPress file uploader here, or at the very least, a progress indicator. But I digress (though, bonus points if you can lead me toward that) - This is going to be an area where clients upload files for us. I need an email to be generated somehow along with this, to an admin. Any ideas?