无法加载请求的文件:helpers/files_helper.php

Posted

技术标签:

【中文标题】无法加载请求的文件:helpers/files_helper.php【英文标题】:Unable to load the requested file: helpers/files_helper.php 【发布时间】:2018-08-25 03:46:57 【问题描述】:

我的 codeignitor 应用程序出错:

能否详细说明问题出在哪里?

文件:autoload.php

<?php
defined('BASEPATH') or exit('No direct script access allowed');

/*
| -------------------------------------------------------------------
| Instructions
| -------------------------------------------------------------------
|
| These are the things you can load automatically:
|
| 1. Packages
| 2. Libraries
| 3. Drivers
| 4. Helper files
| 5. Custom config files
| 6. Language files
| 7. Models
|
*/

/*
| -------------------------------------------------------------------
|  Auto-load Packages
| -------------------------------------------------------------------
| Prototype:
|
|  $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
|
*/
$autoload['packages'] = array();

/*
| -------------------------------------------------------------------
|  Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in system/libraries/ or your
| application/libraries/ directory, with the addition of the
| 'database' library, which is somewhat of a special case.
|
| Prototype:
|
|   $autoload['libraries'] = array('database', 'email', 'session');
|
| You can also supply an alternative library name to be assigned
| in the controller:
|
|   $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array( 'database', 'user_agent', 'image_lib', 'encryption', 'object_cache', 'email', 'app', 'gateways/app_gateway', 'sms' );

$CI = &get_instance();

$CI->load->helper('files');
$gateways = list_files(APPPATH.'/libraries/gateways');

foreach ($gateways as $gateway) 
    $pathinfo =  pathinfo($gateway);
    // Check if file is .php and do not starts with .dot
    // Offen happens Mac os user to have underscore prefixed files while unzipping the zip file.
    if ($pathinfo['extension'] == 'php' && 0 !== strpos($gateway, '.') && $pathinfo['filename'] != 'App_gateway') 
        array_push($autoload['libraries'], 'gateways/'.strtolower($pathinfo['filename']));
    

/*
| -------------------------------------------------------------------
|  Auto-load Drivers
| -------------------------------------------------------------------
| These classes are located in system/libraries/ or in your
| application/libraries/ directory, but are also placed inside their
| own subdirectory and they extend the CI_Driver_Library class. They
| offer multiple interchangeable driver options.
|
| Prototype:
|
|   $autoload['drivers'] = array('cache');
*/
$autoload['drivers'] = array('session');

/*
| -------------------------------------------------------------------
|  Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|
|   $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array(
        'url',
        'file',
        'form',
        'action_hooks',
        'general',
        'misc',
        'func',
        'datatables',
        'custom_fields',
        'defaults',
        'merge_fields',
        'app_html',
        'email_templates',
        'invoices',
        'estimates',
        'credit_notes',
        'proposals',
        'projects',
        'tasks',
        'fields',
        'tickets',
        'relation',
        'tags',
        'pdf',
        'clients',
        'database',
        'upload',
        'sales',
        'themes',
        'theme_style',
        'pre_query_data_formatters',
        'widgets',
        'sms',
        'deprecated',
    );

if (file_exists(APPPATH.'helpers/system_messages_helper.php')) 
    array_push($autoload['helper'], 'system_messages');


if (file_exists(APPPATH.'helpers/my_functions_helper.php')) 
    array_push($autoload['helper'], 'my_functions');

/*
| -------------------------------------------------------------------
|  Auto-load Config files
| -------------------------------------------------------------------
| Prototype:
|
|   $autoload['config'] = array('config1', 'config2');
|
| NOTE: This item is intended for use ONLY if you have created custom
| config files.  Otherwise, leave it blank.
|
*/
$autoload['config'] = array();

/*
| -------------------------------------------------------------------
|  Auto-load Language files
| -------------------------------------------------------------------
| Prototype:
|
|   $autoload['language'] = array('lang1', 'lang2');
|
| NOTE: Do not include the "_lang" part of your file.  For example
| "codeigniter_lang.php" would be referenced as array('codeigniter');
|
*/
$autoload['language'] = array('english');

/*
| -------------------------------------------------------------------
|  Auto-load Models
| -------------------------------------------------------------------
| Prototype:
|
|   $autoload['model'] = array('first_model', 'second_model');
|
| You can also supply an alternative model name to be assigned
| in the controller:
|
|   $autoload['model'] = array('first_model' => 'first');
*/
$autoload['model'] = array( 'misc_model' , 'roles_model' , 'clients_model' , 'tasks_model' );

if(file_exists(APPPATH.'config/my_autoload.php'))
    include_once(APPPATH.'config/my_autoload.php');

这个文件在我的codeigitor应用程序中的路径是application/config/autoload.php 我只是想从基本 URL 登录:http://crm.thecoder.pw/ 我收到此错误:

【问题讨论】:

也许这会对你有所帮助。 ***.com/questions/804399/… @axiac 老兄认真的??它在我的那里:P 试过了,得到 500 错误。 只是出于好奇-您正在自动加载的帮助文件的数量似乎有点奇怪-您在用它们做什么? ;) 【参考方案1】:

助手名称中不应包含大写字母。

【讨论】:

【参考方案2】:

我的解决方案是将我的 custom_helper.phpapplication/helpers/custom_helper.php 移走 到system/helpers/custom_helper.phpapplication/config/autoload.php $autoload['helper'] = array('custom');

重新加载页面,它工作正常

【讨论】:

【参考方案3】:

我认为这是您犯的一个简单错误,请替换以下代码行

$CI->load->helper('files');

通过

$CI->load->helper('file');

【讨论】:

【参考方案4】:

我认为您已经在 application/helpers 文件夹中创建了助手。 您必须在 system/helpers 文件夹而不是 application/helpers 文件夹中创建帮助程序。 然后加载$this-&gt;load-&gt;helper('files');

【讨论】:

【参考方案5】:

没有助手调用files_helper。使用file

$this->load->helper('file');

/config/autoload.php

$autoload['helper'] = array('file');

编辑 01

如果您要创建新助手,请检查 this answer as well

【讨论】:

@downvoter 有什么理由吗?知道你喜欢隐瞒真相 One of the fixes you suggest is already in use in the OP's project 你怎么已经知道了?由于 OP 没有提到第三方帮助程序,因此它来自默认帮助程序文件。 !! 从自动加载中删除这些$CI = &amp;get_instance(); $CI-&gt;load-&gt;helper('files'); 阅读CodeIgniter: Create new helper? @AbdullaNilam 我误读了您答案的第一句话,并根据您建议添加其中一个代码行的错误假设,对它进行了否决。我想撤回我的反对票,但在您修改答案之前不允许我这样做。请编辑答案。

以上是关于无法加载请求的文件:helpers/files_helper.php的主要内容,如果未能解决你的问题,请参考以下文章

Wordpress 无法通过 ajax 请求加载正确的语言 mo 文件

无法加载请求的文件:helpers/files_helper.php

遇到错误无法加载请求的类:身份验证

无法通过 xmlhttprequest 加载本地 xml 文件

由于授权,WKWebview 无法加载资产文件

IIS无法加载字体文件(*.woff,*.svg)的解决办法