I'm a flash developer, but I don't know much (any) PHP. Could someone give me a little help with this code?
I understand that I should have permissions to chmod the file, because it was created with a PHP script. What I want to do is:
if the 'state' variable, passed from flash, = 0, chmod the file to 0444 (read only) then set 'state' to 1 and send back to flash
if the 'state' variable, passed from flash, = 1, chmod the file to 0644 (write/read) then set 'state' to 0 and send back to flash
I'm also looking for a separate piece of code that will check what the chmod is and report back where 0644 = 0, and 0444= 1
This is what I have for the first script but I know it's not right, because I only want the 'state' to change if the chmode returns true.
Thanks for your help!
Code: Select all
<?php
//
$state = $_POST['state'];
if ($state == 0){
chmod("file.xml",0444);
$state = 1;
}else if ($state == 1){
chmod("file.xml",0644);
$state = 2;
}else {
//make it fail
}
echo $state;
?>