Uploading PDF files from the front-end

I have done a simple function for that, but i allow all types of media. So this could be a start:

function insert_attachment( $file_handler, $post_id, $settpdf="false" ) {

  // check to make sure its a successful upload
  if ( $_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK ) __return_false();

  require_once( ABSPATH . 'wp-admin' . '/includes/image.php' );
  require_once( ABSPATH . 'wp-admin' . '/includes/file.php' );
  require_once( ABSPATH . 'wp-admin' . '/includes/media.php' );

  $attach_id = media_handle_upload( $file_handler, $post_id );

  if ( $settpdf ) update_post_meta( $post_id,'_pdf_id', $attach_id );

  return $attach_id;
}

and then a input like: <input type="file" name="uploaded_pdf">

You can retrive the meta like this:

$pdf = get_post_meta($post->ID, '_pdf_id', true);
echo '<a href="'.$pdf.'"><?php __('Download PDF','mytheme'); ?></a>';