Welcome Guest, Not a member yet? Register   Sign In
How to view files content from a different directory
#1

(This post was last modified: 03-01-2022, 10:02 AM by tonyharden.)

Hi all, I'm trying to create links to the files located in different folder with the below link structure(just for reference):

https://mywebsite/index.php/report/generateList

However, when I click on the link links generated, it shows an error 404 Page Not Found.

The folder in question, is in a completely different location(not within Codeigniter directory). So I was wondering if anyone can shed some light on how I can create the link to view the content of the files when click on it?

Here is my code:

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Report extends CI_Controller {

        public function generateList()
        {

                $directory "/apps/text_files/";

                if (is_dir($directory))
                {
                        if ($opendirectory opendir($directory))
                        {
                                while (($file readdir($opendirectory)) !== false)
                                {
                                        echo "<a href='$directory"$file'>$file</a>"."<br>";
                                }
                        closedir($opendirectory);
                        }
                }
        }



Thank you in advance!
Reply
#2

Can you show us your directory structure?
app
system
public
-- assets
-- index.php
etc;

You can try this:
PHP Code:
$directory "/apps/text_files/";

// Try this ../ is up one directory
$directory "apps/text_files/"
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB