I am dynamically creating files using fopen("filename.php", 'a')
I'm able to actually create the files but when I go look at them through the ftp, the files cannot me manipulated. I cannot delete them, I can't put new files into the directory the file is in, and I can't delete the directory that the file is in. I've tried all kinds of things to put in place of 'a' in the fopen command, but nothing has made any difference.
Has anything like this every happened to anyone? Please help, I have no idea what to do anymore.
fopen: created file not editable, why?
Moderator: General Moderators
-
lilsavgrad01
- Forum Newbie
- Posts: 9
- Joined: Thu Jun 09, 2005 9:50 am
-
lilsavgrad01
- Forum Newbie
- Posts: 9
- Joined: Thu Jun 09, 2005 9:50 am
that's the thing though, before I create the file I create the directory and I set the chmod to 777. and the file does get created there but once it's in there when I go to delete the file using my ftp program I am told that I don't have the permission.
now, I tried just creating the directory without putting a file into there and then I'm able to do whatever I want to the file, so it must me something having to do with how I'm creating the file itself.
now, I tried just creating the directory without putting a file into there and then I'm able to do whatever I want to the file, so it must me something having to do with how I'm creating the file itself.
-
lilsavgrad01
- Forum Newbie
- Posts: 9
- Joined: Thu Jun 09, 2005 9:50 am
thanks for checkin this out
Code: Select all
$directory = "../testPages/$DepartmentName";
if ( !$department_handle = mkdir($directory, 0777) )
{
echo "Cannot create directory";
}
//creates default page
if ( !$file_handle = fopen($PageName,'a+b') )
{
die("Cannot open file");
}
if ( !fwrite($file_handle, $PageContent) )
{
die("Cannot write to file");
}
fclose($file_handle);-
lilsavgrad01
- Forum Newbie
- Posts: 9
- Joined: Thu Jun 09, 2005 9:50 am
I'm not sure what your trying to do with "a+b"
did you look at the fopen() function?
http://us3.php.net/manual/en/function.fopen.php
Also check out calling umask(0) before the mkdir() call:
http://us3.php.net/manual/en/function.umask.php
did you look at the fopen() function?
http://us3.php.net/manual/en/function.fopen.php
Also check out calling umask(0) before the mkdir() call:
http://us3.php.net/manual/en/function.umask.php
-
lilsavgrad01
- Forum Newbie
- Posts: 9
- Joined: Thu Jun 09, 2005 9:50 am
yeah, I actually read through all of fopen and found that there's all kinds of things about using just "a" and then you can use "a+".. there's a whole listing and explanation there, and it looks like there are several ways to get this to work, but it's just not happening for me. because all of those settings have to do with the readability and writability of the file, it doesnt seem to have anything to do with whether the file should be deletable or not
thanks for the efforts
thanks for the efforts