我一直在使用前端上传和后期创建脚本。出于某种原因,从“我的项目保存”调用media\\u handle\\u upload函数。php文件作为未定义函数返回。我有什么遗漏吗?权限、其他文件、咖啡?
这是我在函数中的函数。php
function process_attachments() {
//Process Uploads
if (!function_exists(\'wp_generate_attachment_metadata\')){
require_once(ABSPATH . "wp-admin" . \'/includes/image.php\');
require_once(ABSPATH . "wp-admin" . \'/includes/file.php\');
require_once(ABSPATH . "wp-admin" . \'/includes/media.php\');
}
if ($_FILES) {
foreach ($_FILES as $file => $array) {
if ($_FILES[$file][\'error\'] !== UPLOAD_ERR_OK) {
return "upload error : " . $_FILES[$file][\'error\'];
}
$attach_id = media_handle_upload( $file, $post_id );
}
}
//Attachment ID if set
if ($attach_id > 0){
//and if you want to set that image as Post then use:
return $attach_id;
}
}
我从我的项目save中调用这个。php文件(这是精简的,我觉得没有必要显示创建后的表单数据)
$attach_id = process_attachments();
if($attach_id > 0) {
//and if you want to set that image as Post then use:
$whimkey->attach_id = $attach_id;
}
自
media_handle_upload
是一个
Wordpress function 它怎么可能是未定义的?