本文整理汇总了PHP中acf_upload_files函数的典型用法代码示例。如果您正苦于以下问题:PHP acf_upload_files函数的具体用法?PHP acf_upload_files怎么用?PHP acf_upload_files使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了acf_upload_files函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_files
function save_files($post_id = 0)
{
// bail early if no $_FILES data
if (empty($_FILES['acf']['name'])) {
return;
}
// upload files
acf_upload_files();
}
示例2: acf_upload_files
function acf_upload_files($ancestors = array())
{
// vars
$file = array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => '', 'size' => '');
// populate with $_FILES data
foreach (array_keys($file) as $k) {
$file[$k] = $_FILES['acf'][$k];
}
// walk through ancestors
if (!empty($ancestors)) {
foreach ($ancestors as $a) {
foreach (array_keys($file) as $k) {
$file[$k] = $file[$k][$a];
}
}
}
// is array?
if (is_array($file['name'])) {
foreach (array_keys($file['name']) as $k) {
$_ancestors = array_merge($ancestors, array($k));
acf_upload_files($_ancestors);
}
return;
}
// bail ealry if file has error (no file uploaded)
if ($file['error']) {
return;
}
// assign global _acfuploader for media validation
$_POST['_acfuploader'] = end($ancestors);
// file found!
$attachment_id = acf_upload_file($file);
// update $_POST
array_unshift($ancestors, 'acf');
acf_update_nested_array($_POST, $ancestors, $attachment_id);
}