Setting File Permissions in Windows with PHP

后端 未结 2 1424
时光取名叫无心
时光取名叫无心 2021-01-01 00:06

I have a script that uploads a *.csv to import into a DB table that I have which works great in linux through chmod($target, 0777); but I can\'t for the life of

2条回答
  •  灰色年华
    2021-01-01 00:46

    While Brian Leishman's answer will work, if you do not have the ability to edit permissions on the temp folder, you can make your uploaded file inherit permissions from its new location manually with the following on the command line:

    icacls "target.txt" /q /c /reset
    

    So, using PHP's exec() function:

    exec( 'icacls "target.txt" /q /c /reset' );
    

    For details of the various icacls flags, see: https://technet.microsoft.com/en-us/library/cc753525.aspx

    Tip: Using the /t flag, you can use pattern matching to process multiple files.

提交回复
热议问题