permission errors with creating files on a unix server.

Hey guys, doing an assignment for uni, we are hosting our websites on the uni’s unix server, with less then maximum permissions. I am trying to create a file to unlink images whenever i need to delete them. Yesterday they were working and I am not sure what i changed in the last 24 hours that caused me to start getting errors.

The file, when it opened, wrote to it correctly, the problem seems to be creating it using fopen().

The code is as follows:

function create_unlink($uID, $filename){
$file1 = $uID.“unlink.php”;

$file = fopen($file1, 'w') or die("can't open file");

$data = "<?php\nunlink(\"$filename\");\n?>";

fwrite($file, $data);

fclose($file);

return $file1;

}

The error is: Warning: fopen(38unlink.php): failed to open stream: Permission denied in /net/homes.ict.griffith.edu.au/export/home/s2763543/public_html/wp/assign2/includes/defs.php on line 477 can’t open file

This file is being created in my base directory for the files, which has absolute permissions. I hope this is the right place to put this topic, any ideas?

Probably you’ve uploaded that file via FTP under your user, and now php cannot open it for writing, because php and Apache are running under other user. Try to delete this file, and have your php script create it again.

Sorry, I should have made it clear, I am running the script as part of my website, I am not creating the file separately as it has to be unique for each person, so that it deletes the right images when I run the unlink file. It gave me no error when I create the file manually, but instead didn’t write anything to it or move it like it was supposed to, so something is going wrong there. Just not sure where.

Anyone else able to help?

Sponsor our Newsletter | Privacy Policy | Terms of Service