您需要本地路径才能添加附件:
// add the file to the media library
$attachment = array(
\'post_mime_type\' => \'image/png\' // the MIME type
, \'post_title\' => \'Attachment title\'
);
// Adds the file to the media library and generates the thumbnails.
$attach_id = wp_insert_attachment( $attachment, $path ); // PATH!