wp_handle_sideload()移动文件到上传目录中

目录

描述

Handle sideloads, which is the process of retrieving a media item from another server instead of a traditional media upload. This process involves sanitizing the filename, checking extensions for mime type, and moving the file to the appropriate directory within the uploads directory.

wp_handle_sideload() 描述

用法

<?php wp_handle_sideload( &$file$overrides$time ); ?>

wp_handle_sideload() 用法

参数

$file

(array) (必填) an array similar to that of a PHP $_FILES POST array

默认值: None

$overrides

(array) (可选) An associative array of names => values to override default variables with extract( $overrides, EXTR_OVERWRITE ).

默认值: false

$time

(string) (可选) Time formatted in 'yyyy/mm', gets passed to wp_upload_dir() to override the default upload directory.

默认值: null

wp_handle_sideload() 参数

返回值

(array

On success, returns an associative array of file attributes. On failure, returns the return of the upload error handler, which by default would be array( 'error' => $message ).

wp_handle_sideload() 返回值

示例

This example uses download_url() to download the logo from wordpress.org and then moves it into the uploads directory.

wp_handle_sideload() 示例

历史

添加于 版本: 2.6.0

wp_handle_sideload() 历史

源文件

wp_handle_sideload() 函数的代码位于 wp-admin/includes/file.php

wp_handle_sideload() 源文件

相关