Welcome Guest, Not a member yet? Register   Sign In
file does not exist error while reading a file
#1

[eluser]alberta[/eluser]
I have uploaded my files in folder named 'uploads' placed in root directory setting permissions to 777.
Now i want to read file

Code:
$file ='./uploads/'.$filename;
        if (file_exists($file)) {
            $data['value'] =  "The file $filename exists";
        } else {
            $data['value'] =  "The file $filename does not exist";
        }

        $data['string']= read_file('./uploads/'.$filename);

but it is giving error "file doesn't exist". Where is mistake ?

Thanks in advance
#2

[eluser]Jagar[/eluser]
Where is the uploads directory located it, is at the root of you site?
#3

[eluser]Jagar[/eluser]
If your site is http://localhost/mysite then it's expecting to be http://localhost/mysite/uploads

I hope that helps!
#4

[eluser]jedd[/eluser]
I'd suggest you use base_url() (or one of the variants) in preference to hard-coding './uploads'.

It looks like you're just confused about where the directory is in relation to where you think CI is - in a metaphysical kind of way.

A handy hint for future reference (I'm assuming you're running Apache2 here) is to, as root, run this command to watch the error log - as you hit the page you'll see if the server's tried to look for a file in a particular place, and failed:
Code:
#   tail  -f  /var/log/apache2/error.log




Theme © iAndrew 2016 - Forum software by © MyBB