upload_file()

Upload a file

upload()

Upload a file to the cloud using a simple file object.

Parameters

Name
Type
Description

$file

File object

Object containing the file details. Same as file object in $_FILES.

$upload_folder_id

string

ID of the upload folder.

$description

string

Description for the file.

$overwrite

bool

Overwrite an existing file with the same name? If false, the file will be renamed.

Return

Name
Type
Description

$node

CachedNode

The object for the uploaded file.

Usage

WPCP_ONEDRIVE_API::set_account_by_id('8c9bacda0-d8d8-4b22-b634-7b5281687575');
WPCP_ONEDRIVE_API::set_drive_by_id('b!DlaHWskCed_MIid3KpJH5Lbatf9HsdXBAZH5YcvPAbMhJUKzTJyzgvXZYpBS');

// File location on server
$file_path = '/absolute/path/to/file/on/server.ext';

// Create File object
$file = (object) [
    'tmp_path' => $file_path,
    'type' => mime_content_type($file_path),
    'name' => 'filename.ext',
    'size' => filesize($file_path),
];

$entry = WPCP_ONEDRIVE_API::upload_file($file, '01EXLSWHRCD7RDL3HX65BK5X3ULXLWSICN', 'A simple description', false);

Last updated