Route uploads through async-upload.php instead of admin-ajax.php.

Props nacin, koopersmith
fixes #22622


git-svn-id: http://core.svn.wordpress.org/trunk@22902 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2012-11-28 20:17:57 +00:00
parent 51b6b2189b
commit ea0d28db29
2 changed files with 25 additions and 11 deletions

View File

@ -13,21 +13,35 @@ if ( defined('ABSPATH') )
else
require_once('../wp-load.php');
// Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
$_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
elseif ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
$_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
if ( empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie']) )
$_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie'];
unset($current_user);
require_once('./admin.php');
if ( ! ( isset( $_REQUEST['action'] ) && 'upload-attachment' == $_REQUEST['action'] ) ) {
// Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
$_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
elseif ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
$_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
if ( empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie']) )
$_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie'];
unset($current_user);
}
header('Content-Type: text/html; charset=' . get_option('blog_charset'));
require_once('./admin.php');
if ( !current_user_can('upload_files') )
wp_die(__('You do not have permission to upload files.'));
header('Content-Type: text/html; charset=' . get_option('blog_charset'));
if ( isset( $_REQUEST['action'] ) && 'upload-attachment' === $_REQUEST['action'] ) {
define( 'DOING_AJAX', true );
include ABSPATH . 'wp-admin/includes/ajax-actions.php';
send_nosniff_header();
nocache_headers();
wp_ajax_upload_attachment();
die( '0' );
}
// just fetch the detail form for that attachment
if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) {
$post = get_post( $id );

View File

@ -1246,7 +1246,7 @@ function wp_plupload_default_settings() {
'file_data_name' => 'async-upload', // key passed to $_FILE.
'multiple_queues' => true,
'max_file_size' => $max_upload_size . 'b',
'url' => admin_url( 'admin-ajax.php', 'relative' ),
'url' => admin_url( 'async-upload.php', 'relative' ),
'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
'filters' => array( array( 'title' => __( 'Allowed Files' ), 'extensions' => '*') ),