Note that there are some explanatory texts on larger screens.

plurals
  1. POchmod setting the permissions value dynamicly
    primarykey
    data
    text
    <p>Ok test 1 and 2 work fine, but If I cast the value from an array it doesn't work.</p> <pre><code>$file = '/test/file.xlsx'; echo "Original Permissions: ".substr(decoct(fileperms($file)),2)."&lt;br /&gt;\n\r"; // test 1 $permission = 0775; chmod($file,$permission); clearstatcache(); echo "Test 1 Permissions: ".substr(decoct(fileperms($file)),2)."&lt;br /&gt;\n\r"; // test 2 define("PERMISSION", 0775); chmod($file,PERMISSION); clearstatcache(); echo "Test 2 Permissions: ".substr(decoct(fileperms($file)),2)."&lt;br /&gt;\n\r"; </code></pre> <p>Output:</p> <pre><code>Original Permissions: 1407&lt;br /&gt; Test 1 Permissions: 0775&lt;br /&gt; Test 2 Permissions: 0775&lt;br /&gt; </code></pre> <p>Why doesn't this work?</p> <pre><code>// $ini_array['excel_file_info']['excel_file_permission'] // is in a ini file with the value set to 0775 if(isset($ini_array['excel_file_info']['excel_file_permission'])) { $excel_file_permission = $ini_array['excel_file_info']['excel_file_permission']; define("EXCEL_FILE_PERMISSION", $excel_file_permission); } else { $excel_file_permission = 0777; define("EXCEL_FILE_PERMISSION", $excel_file_permission); } echo "Permissions Before chmod: ".substr(decoct(fileperms($file)),2)."&lt;br /&gt;\n\r"; chmod($file,EXCEL_FILE_PERMISSION); clearstatcache(); echo "Permissions After chmod: ".substr(decoct(fileperms($file)),2)."&lt;br /&gt;\n\r";; chmod($file,0755); clearstatcache(); echo "Permissions Hard Coded chmod: ".substr(decoct(fileperms($file)),2)."&lt;br /&gt;\n\r";; </code></pre> <p>I get this for file permissions:</p> <pre><code>// Before I chmod Permissions Before chmod: 0644&lt;br /&gt; // Using the DEFINED CONSTANT w/ set value to 0775 Permissions After chmod: 1363&lt;br /&gt; // Hard Coded 0755 Permissions Hard Coded chmod: 0755&lt;br /&gt; </code></pre> <p>EDIT:</p> <pre><code>// test 3 $permission = array('perm' =&gt; 0775); chmod($file,$permission['perm']); clearstatcache(); echo "Test 3 Permissions: ".substr(decoct(fileperms($file)),2)."&lt;br /&gt;\n\r"; </code></pre> <p>Test 3 works, but still not the main example. UGH!!!</p> <p>EDIT #2:</p> <p>I think I found the problem, when I echo the type of the variable it's a string.</p> <pre><code>echo "Defined Excel File Permission: ".EXCEL_FILE_PERMISSION."\n\r"; echo "Defined Type: ".gettype(EXCEL_FILE_PERMISSION)."\n\r"; Defined Excel File Permission: 0775 Defined Type: string </code></pre> <p>Why is this? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload