PHP chmod function wont work

627 Views Asked by At

A wont work problem.

I have a XHR file upload to a directory. There is a button the user presses on the site which executes php code. On that code I placed the function chmod($file_name, 0777);. Never mind the security issues, but this is not working. I'm baffled.

<?php
$file_name = $_REQUEST["file_name"];
chmod($file_name, 0777);
?>

The javascript sends the file name and I echo'ed the variable for the correct value. Thats not the problem.

$("#csv_dedupe").live("click", function(e) {
    file_name = 'http://hidden/files/' + $("#IMEXp_import_var-uploadFile-file").val();
    $.post($_CFG_PROCESSORFILE, {"task": "csv_dupe", "file_name": file_name}, function(data) {
        alert(data);
    }, "json")
});

I tried other solutions like changing the umask in my /etc/profile and my /etc/bashrc and rebooting, but it did not work. The reason I tried these is because ultimately I just want to change the directory's default chmod.

I am running on a virtual centos server. Its LAMP. What am I doing wrong?

1

There are 1 best solutions below

5
On BEST ANSWER

You're using a decimal literal instead of an octal literal.

chmod($file_name, 0777);