Welcome Guest, Not a member yet? Register   Sign In
cant create ,write with the file helper [SOLVED]
#1

[eluser]kosaidpo[/eluser]
i can only read a text file the write function does nothin also get_filenames too
btw im on ubuntu usin lampp , and yes i have the pemissions but i dont kno why icant do anythin

when i do

Code:
if($nom=get_filenames($path)){
print_r($nom) ;
}
else{
echo 'no' ;
}

i got no displayed
tnx fo your help Big Grin
#2

[eluser]vitoco[/eluser]
is path correct ??, try to do this
Code:
echo 'REALPATH:[['.realpath($path).']]';
if( ! is_dir( $path ) )
{
    echo 'DIR EXISTS' ;
}
else
{
    echo "DIR DOESN'T EXISTS" ;
}
if($nom=get_filenames($path)){
print_r($nom) ;
}
else{
echo 'no' ;
}

i got no displayed
tnx fo your help Big Grin[/quote]
#3

[eluser]kosaidpo[/eluser]
tnx dude now ican only read but i cant create files with write_file
and your code gave me a yes does exist
#4

[eluser]WanWizard[/eluser]
Note that in the code of vitoco, the true and false is reversed due to the "! is_dir()" test.

So if it says "DIR EXISTS", it means the path is NOT correct!
#5

[eluser]kosaidpo[/eluser]
hii tnx for replyin
yeh i didnt notice it but well

i got the application folder out of the system and
and this is my function ican read but cant write (even im pretty sure that im the owner of this hole folder htdocs)

Code:
function write(){

$this->load->helper('file') ;
$path="application/controllers/file.txt" ;

echo $path .'<br>' ;
        $data='this is a test' ;
        write_file($path ,$data) ;
        
        $txt=read_file($path) ;
        echo $txt ;

tnx for help
#6

[eluser]WanWizard[/eluser]
What does
Code:
$path="application/controllers/file.txt" ;
echo realpath($path);
tell you?

You have to be very careful when working with relative paths. It is better to use
Code:
$path = APPPATH . "controllers/file.txt";
#7

[eluser]kosaidpo[/eluser]
the realpath give me the hole path

/opt/lampp/htdocs/www/CI_forum/application/controllers/file.txt

but to be honest idont kno wht does it refer to but the APPPATH refers to the application folder
correct me please/tnx

and still cant write Sad
#8

[eluser]WanWizard[/eluser]
APPPATH points to the application directory, correct. If you use it you don't have possible relative path issues.

If you are sure the path is correct, it must be a rights issue. Check every directory, starting from the root, to make sure your apache user has X rights on every directory, and XW rights on '/opt/lampp/htdocs/www/CI_forum/application/controllers/'.
#9

[eluser]kosaidpo[/eluser]
yeh thats the only thing i guess but you got to see this

Code:
xsaiddx@xsaiddx-laptop:~$ ls -ld /opt/lampp/htdocs/www/CI_forum/application/controllers/
drwxr-xr-x 2 xsaiddx xsaiddx 4096 2010-05-22 16:46 /opt/lampp/htdocs/www/CI_forum/application/controllers/

you advice me to check sumthin else other than that

tnx
#10

[eluser]WanWizard[/eluser]
Who or wat is xsaiddx? Because that is the only user with write rights in that folder.
So that solves the mistery, as mentioned way up in this thread, your apache user doesn't have write rights.




Theme © iAndrew 2016 - Forum software by © MyBB