3 /* This accepts file uploads from swfupload or other asynchronous upload methods.
7 if ( defined('ABSPATH') )
8 require_once( ABSPATH . 'wp-config.php');
10 require_once('../wp-config.php');
12 // Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
13 if ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
14 $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
16 require_once('admin.php');
18 header('Content-Type: text/plain');
20 if ( !current_user_can('upload_files') )
21 wp_die(__('You do not have permission to upload files.'));
23 // just fetch the detail form for that attachment
24 if ( ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) {
25 echo get_media_item($id);
29 $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
30 if (is_wp_error($id)) {
31 echo '<div id="media-upload-error">'.wp_specialchars($id->get_error_message()).'</div>';
35 if ( $_REQUEST['short'] ) {
36 // short form response - attachment ID only
40 // long form response - big chunk o html
41 $type = $_REQUEST['type'];
42 echo apply_filters("async_upload_{$type}", $id);