我用过this tutorial 使用Ajax构建选项页面表单。
现在,我想使用wp\\u handle\\u upload来上传图像。我试过这个http://pastebin.com/35HW8RSZ 但没有成功。
我们将不胜感激。Asaf。
我用过this tutorial 使用Ajax构建选项页面表单。
现在,我想使用wp\\u handle\\u upload来上传图像。我试过这个http://pastebin.com/35HW8RSZ 但没有成功。
我们将不胜感激。Asaf。
我找到了一个非常简单的解决方案here. 在我看来,它超过了任何外部Ajax解决方案。
您需要包含一些文件才能获取wp_handle_upload
为了工作,我有一个功能:
function My_wp_handle_upload($file_handler,$overrides) {
// check to make sure its a successful upload
if ($_FILES[$file_handler][\'error\'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . \'/includes/image.php\');
require_once(ABSPATH . "wp-admin" . \'/includes/file.php\');
require_once(ABSPATH . "wp-admin" . \'/includes/media.php\');
$upload = wp_handle_upload( $file_handler, $overrides );
return $upload ;
}
因此,将此函数添加到文件后,只需将调用更改为:$file = wp_handle_upload($data[\'MoobLogoUpload\'], $overrides);
收件人:$file = My_wp_handle_upload($data[\'MoobLogoUpload\'], $overrides);
更新刚刚记住,您必须使用ajax上传解决方案,如:由于无法使用浏览器的XMLHttpRequest对象上载文件,因此可以通过iframe上载或提交任何其他插件
你好,朋友们,我正在尝试让我的wordpress帖子显示在非wordpress应用程序中。目前,我正在使用以下方法获取它们。我的wordPress页面是这样的:<div id=\"header\"> <!-- header content goes here --> </div> <div id=\"main-body\"> <div id=\"content\">