Welcome Guest, Not a member yet? Register   Sign In
  Bugs in Tutorial CI4
Posted by: michel42 - 06-17-2025, 04:24 AM - Replies (6)

Hi CodeIgniter Team,
just started learning Codeigniter and doing step by step your Tutorial.
In:
https://codeigniter.com/user_guide/tutor...how-method
In Controller also in Method you use show instead of view and that doesn't work, it should be named to view
Should be changed in Routing "Routes.php", in Controller "News.php"
it was mixed with view and show


  How to display uploaded file from writable/uploads
Posted by: paulgough - 06-17-2025, 01:44 AM - Replies (1)

Hello,
I have a question. In CodeIgniter 4, how can I display the path of an uploaded file from the writable/uploads folder?

I upload various file types including images, documents, PDFs, and CSVs using the following code and store the file paths in the database.

Code:
$file->move(WRITEPATH . 'uploads', $fileName);


All uploaded records are listed on a page, and I need to open the uploaded CSV or Excel files in a new tab from this listing page.

However, I’m unable to retrieve the path from the writable/uploads folder to open it in a new tab.

Code:
<?=WRITEPATH.'uploads/'.$allList->documentCsv?>


When I copy the link and try to open it in a new tab, it downloads instead of displaying the file.

Could you please explain how to properly show the file path?


Wink trim(): Argument #1 ($string)
Posted by: exoed - 06-16-2025, 07:47 PM - No Replies

everytime i create a new project in CI4 4.6.1 with php 8.2.12 i often get this error, what is wrong?

this error comes out when i first run my application.


trim(): Argument #1 ($string) must be of type string, array given 
error at :  SYSTEMPATH\Filters\Filters.php at line 918

911      * @param array  $paths The except path patterns
912      */
913    private function checkPseudoRegex(string $uri, array $paths): bool
914    {
915        // treat each path as pseudo-regex
916        foreach ($paths as $path) {
917            // need to escape path separators
918            $path = str_replace('/', '\/', trim($path, '/ '));
919            // need to make pseudo wildcard real
920            $path = strtolower(str_replace('*', '.*', $path));
921
922            // Does this rule apply here?
923            if (preg_match('#\A' . $path . '\z#u', $uri, $match) === 1) {
924                return true;
925            }

log :
CRITICAL - 2025-06-17 01:45:17 --> TypeError: trim(): Argument #1 ($string) must be of type string, array given
[Method: GET, Route: /]
in SYSTEMPATH\Filters\Filters.php on line 918.
 1 SYSTEMPATH\Filters\Filters.php(918): trim([...], '/ ')
 2 SYSTEMPATH\Filters\Filters.php(881): CodeIgniter\Filters\Filters->checkPseudoRegex('', [...])
 3 SYSTEMPATH\Filters\Filters.php(791): CodeIgniter\Filters\Filters->pathApplies('', [...])
 4 SYSTEMPATH\Filters\Filters.php(474): CodeIgniter\Filters\Filters->processFilters('')
 5 SYSTEMPATH\Filters\Filters.php(218): CodeIgniter\Filters\Filters->initialize('')
 6 SYSTEMPATH\CodeIgniter.php(479): CodeIgniter\Filters\Filters->run('', 'before')
 7 SYSTEMPATH\CodeIgniter.php(354): CodeIgniter\CodeIgniter->handleRequest(null, Object(Config\Cache), false)
 8 SYSTEMPATH\Boot.php(334): CodeIgniter\CodeIgniter->run()
 9 SYSTEMPATH\Boot.php(67): CodeIgniter\Boot::runCodeIgniter(Object(CodeIgniter\CodeIgniter))
10 FCPATH\index.php(59): CodeIgniter\Boot::bootWeb(Object(Config\Paths))
11 SYSTEMPATH\rewrite.php(44): require_once('C:\\xampp\\htdocs\\geminimenu\\public\\index.php')


 how can i solve this?


  transStatus error
Posted by: okatse - 06-16-2025, 11:27 AM - Replies (4)

Hi
What am I doing wrong?

PHP Code:
        $edb = \Config\Database::connect();
        $res $edb->prepare(function ($edb) {
            $query "select * from test limit :limit";
            return $edb->query($query);
        });
        $edb->transStart();
        $results $res
            
->execute(['limit' => 1])
            ->getResultArray();
        $edb->transComplete(); 
Cannot access protected property CodeIgniter\Database\Postgre\Connection::$transStatus
\Database\BasePreparedQuery.php at line 141


  Multi-dimensional Array in POST
Posted by: Gian - 06-16-2025, 10:30 AM - Replies (3)

Hi,
I make an AJAX request in POST to CI, sending some data, including some data in the format:

Code:
const args: {
"field1": {"field2":value}
};


If I print $this->request->getPost(), I display:

PHP Code:
Array(
  [field1] => Array
    (
        [field2] => value
    
)


but if I try to print $this->request->getPost(field1.field2) I always get an empty value.

Am I wrong in the declaration?


  Site main page is not working
Posted by: sslion - 06-15-2025, 04:25 AM - Replies (3)

Good afternoon. We have a website running on Codeigniter 4. The website has been working stably for more than three years, but yesterday something happened and the main page of the website stopped working, the server issues a 500 error. However, all other pages of the site are working correctly. Part of the server log is attached.
How can I fix this error?

PHP Fatal error: Uncaught ErrorException: file_get_contents(/home/c/ck42654/app/Config/Modules.php): failed to open stream: Permission denied in /home/c/ck42654/vendor/codeigniter4/framework/system/Autoloader/FileLocator.php:172
Stack trace:
#0 [internal function]: CodeIgniter\\Debug\\Exceptions->errorHandler(2, 'file_get_conten...', '/home/c/ck42654...', 172, Array)
#1 /home/c/ck42654/vendor/codeigniter4/framework/system/Autoloader/FileLocator.php(172): file_get_contents('/home/c/ck42654...')
#2 /home/c/ck42654/vendor/codeigniter4/framework/system/Config/Config.php(150): CodeIgniter\\Autoloader\\FileLocator->getClassname('/home/c/ck42654...')
#3 /home/c/ck42654/vendor/codeigniter4/framework/system/Config/Config.php(83): CodeIgniter\\Config\\Config::createClass('Modules')
#4 /home/c/ck42654/vendor/codeigniter4/framework/system/Common.php(126): CodeIgniter\\Config\\Config::get('Modules', true)
#5 /home/c/ck42654/vendor/codeigniter4/framework/system/Config/BaseConfig.php(85): config('Modules')
#6 /home/c/ck42654/vendor/codeigniter4/fra in /home/c/ck42654/vendor/codeigniter4/framework/system/Autoloader/FileLocator.php on line 172


  running codeigniter in a subdirectory + legacy autorouting results in 404
Posted by: Franky 5831 - 06-13-2025, 10:53 AM - Replies (8)

I have a codeigniter 4 app that has to live in a shared hosting enviroment and has to be in a subdirectory.
The app has been developed with legacy autorouting enabled.
The app has indexPage as index.php

All the autorouting routes end up throwing a 404 with the "index.php is not a valid controller name" statement.

1. Steps to Reproduce
2. get an apache webserver
3. set indexPage  as index.php in your app/Config/App.php
4. install codeigniter in a subdirectory:
/var/www/html/code-igniger-app
/var/www/html/other-apps-here
this way you'll access the app from http://localhost:8080/code-igniger-app/index.php
5. enable legacy autorouting and create a controller

The problem seems to be that having codeigniter 4 in a subdirectory results in the $_SERVER["SCRIPT_NAME"] variable to become: "/code-igniger-app/public/index.php".
If the SCRIPT_NAME has "/public" the parseRequestURI method from the CodeIgniter\HTTP\SiteURIFactory class on line 137 does not remove "/code-igniger-app/index.php" from the uri and it tries to use index.php as the controller name.

I have opened this issue on github: https://github.com/codeigniter4/CodeIgni...ssues/9602 but I've been told this is a misconfiguration, I tried to follow the official guide but I could not get it to work, can someone help me figure out where I've gone wrong?
Thanks


  Site main page is not working
Posted by: sslion - 06-13-2025, 07:19 AM - No Replies

Good afternoon. We have a website running on Codeigniter 4. The website has been working stably for more than three years, but yesterday something happened and the main page of the website stopped working, the server issues a 500 error. However, all other pages of the site are working correctly. Part of the server log is attached.

PHP Fatal error: Uncaught ErrorException: file_get_contents(/home/c/ck42654/app/Config/Modules.php): failed to open stream: Permission denied in /home/c/ck42654/vendor/codeigniter4/framework/system/Autoloader/FileLocator.php:172
Stack trace:
#0 [internal function]: CodeIgniter\\Debug\\Exceptions->errorHandler(2, 'file_get_conten...', '/home/c/ck42654...', 172, Array)
#1 /home/c/ck42654/vendor/codeigniter4/framework/system/Autoloader/FileLocator.php(172): file_get_contents('/home/c/ck42654...')
#2 /home/c/ck42654/vendor/codeigniter4/framework/system/Config/Config.php(150): CodeIgniter\\Autoloader\\FileLocator->getClassname('/home/c/ck42654...')
#3 /home/c/ck42654/vendor/codeigniter4/framework/system/Config/Config.php(83): CodeIgniter\\Config\\Config::createClass('Modules')
#4 /home/c/ck42654/vendor/codeigniter4/framework/system/Common.php(126): CodeIgniter\\Config\\Config::get('Modules', true)
#5 /home/c/ck42654/vendor/codeigniter4/framework/system/Config/BaseConfig.php(85): config('Modules')
#6 /home/c/ck42654/vendor/codeigniter4/fra in /home/c/ck42654/vendor/codeigniter4/framework/system/Autoloader/FileLocator.php on line 172

How can I fix this error?


  Shield problem redirecting in hosting
Posted by: pippuccio76 - 06-13-2025, 07:14 AM - Replies (8)

Hi , i have an application that work fine in localhost .

I upload file on hosting but when i try to login with shield it return on login page without error message , if i see log i have : 

INFO - 2025-06-13 15:53:33 --> REDIRECTED ROUTE at https://mysite.it/login

it seem that not save user session:
__ci_last_regenerate|i:1749823269;csrf_test_name|s:32:"06d7c9016ed344db8ac20881c5c05d79";_ci_previous_url|s:38:"https://mysite.it/index.php/login";

wath can i do ?


  These 20 Awesome API Clients Will Change How You Work with APIs
Posted by: InsiteFX - 06-12-2025, 07:41 AM - Replies (1)

These 20 Awesome API Clients Will Change How You Work with APIs


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
AssetConnect - a powerful...
by Crenel
13 minutes ago
twig and view cell
by foxbille
Yesterday, 01:58 AM
Best Way to Implement Aff...
by InsiteFX
07-04-2025, 09:58 PM
The pipe operator in PHP ...
by InsiteFX
07-04-2025, 04:18 PM
Heads up for users using ...
by FlavioSuar
07-04-2025, 11:33 AM
Table (view class) Row ID
by grimpirate
07-03-2025, 11:22 PM
curl + response body
by michalsn
07-03-2025, 10:10 PM
Happy 4th Everyone
by InsiteFX
07-03-2025, 09:31 PM
AbuseIPDB Module
by InsiteFX
07-03-2025, 09:27 PM
tool bar not showing
by Luiz Marin
07-03-2025, 04:46 AM

Forum Statistics
» Members: 155,043
» Latest member: skecherscomvn
» Forum threads: 78,441
» Forum posts: 379,733

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB