如何修复“ Wordpress” wp-admin / includes / file.php”错误代码-500

时间:2019-04-04 11:44:36

标签: php wordpress file

我正在WordPress前端设置多个文件上传。 我遵循这个“ http://www.kvcodes.com/2013/12/create-front-end-multiple-file-upload-wordpress/” 添加时出现错误代码500

require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');

这个。

我添加了这个

require_once('../../../wp-admin/includes/image.php');
require_once('../../../wp-admin/includes/file.php');
require_once('../../../wp-admin/includes/media.php');

” 在file.php中仅得到-500错误

我的代码:

if( 'POST' == $_SERVER['REQUEST_METHOD']  ) {
if ( $_FILES ) { 
        $files = $_FILES["kv_multiple_attachments"];  
        foreach ($files['name'] as $key => $value) {            
                if ($files['name'][$key]) {
                    $file = array( 
                        'name' => $files['name'][$key],
                        'type' => $files['type'][$key], 
                        'tmp_name' => $files['tmp_name'][$key], 
                        'error' => $files['error'][$key],
                        'size' => $files['size'][$key]
                    ); 
                     $_FILES = array ("kv_multiple_attachments" => $file); 
                    //var_dump($_FILES);
                    foreach ($_FILES as $file => $key) {
                        $pid = "1";
                        $newupload = kv_handle_attachment($file,$pid); 
                    }
                } 
            } 
        }

}
function kv_handle_attachment($file_handler,$post_id,$set_thu=false) {
    // check to make sure its a successful upload
    if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
//echo "ss";
    require_once('../../../wp-admin/includes/image.php');
    require_once('../../../wp-admin/includes/file.php');
    require_once('../../../wp-admin/includes/media.php');
echo "ss";
    $attach_id = media_handle_upload( $file_handler, $post_id );

         // If you want to set a featured image frmo your uploads. 
    if ($set_thu) set_post_thumbnail($post_id, $attach_id);
    return $attach_id;
}

0 个答案:

没有答案