Welcome Guest, Not a member yet? Register   Sign In
error "failed to open stream: Permission denied" when creating a php text file
#1

[eluser]SidharthaXx[/eluser]
Hi All,

I'm trying to create an attachment file in my controller, very simple test code as below,

function create_vcal() {

$ourFileName = "/home/robbiedb/Downloads/bobber.ics";
echo "got here";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
$stringData = "Bobby Bopper\n";
fwrite($ourFileHandle, $stringData);
fclose($ourFileHandle);

}

Anyway, I'm getting an error "failed to open stream: Permission denied". This suprises me, since I'm trying to access my local hard drive under my user "robbiedb"...

Anyone know why I might be getting this error?

Thanks
#2

[eluser]Mario "St.Peter" Valentino[/eluser]
i think you should chmod the folder
chmod -R 777 folder_name or file
#3

[eluser]InsiteFX[/eluser]
You do not want to chmod to 777

This is what you want to do and you can do it with PHP
Code:
// Read and write for owner, read for everybody else
chmod("/somedir/somefile", 0644);

PHP.NET
CHMOD




Theme © iAndrew 2016 - Forum software by © MyBB