matometaru
1/16/2018 - 6:43 AM

ファイルアップ関連の返り値

<form enctype="multipart/form-data">
	<input type="file" name="image">
</form>

echo "<pre>";
print_r($_FILES['image']);
echo "</pre>";
array(
	['name'] => 'ss.png',
	['type'] => 'image/png',
	['tmp_name'] => 'D:\xampp\tmp\php655A.tmp',
	['error'] => '0',
	['size'] => '4785',
);

$new_file_path_objects = wp_upload_dir();
echo "<pre>";
print_r($new_file_path_objects);
echo "</pre>";
array(
    ['path'] => "D:\works\project\root\wordpress/wp-content/uploads/2018/01",
    ['url'] => "http://project.local/wordpress/wp-content/uploads/2018/01",
    ['subdir'] => "/2018/01",
    ['basedir'] => "D:\works\project\root\wordpress/wp-content/uploads",
    ['baseurl'] => "http://project.local/wordpress/wp-content/uploads",
    ['error'] => "",
)