sys_get_temp_dir in shared hosting environment

后端 未结 7 1671
日久生厌
日久生厌 2021-01-31 10:27

Note: This could also fit in superuser.

I am setting up PHP 5.3.10 on a shared host with apache2 mpm itk and open_basedir in a way, that each user may not see o

7条回答
  •  忘掉有多难
    2021-01-31 10:50

    Looking at the PHP source, sys_get_temp_dir() works with the following priority:

    1. If its value has been calculated before, the cached value is used.
    2. sys_temp_dir is checked in the ini configuration.
    3. On Windows, the GetTempPathW Win32 API method is used, and according to its documentation the following are used (in this order):
      1. The path specified by the TMP environment variable.
      2. The path specified by the TEMP environment variable.
      3. The path specified by the USERPROFILE environment variable.
      4. The Windows directory.
    4. In *nix, the following are used (in this order):
      1. The TMPDIR environment variable.
      2. The P_tmpdir macro
      3. /tmp (according to the source, this is a last-ditch effort that should never happen).

    That should give you enough options for controlling the result of sys_get_temp_dir (e.g. ini_set('sys_temp_dir', $tmpPath) or putenv('TMPDIR=/foo/bar') as others mentioned) Unless it was previously calculated, in which case you're SOL as far as I know and the cached value will be used (but I have zero knowledge in PHP so would love to hear otherwise).

提交回复
热议问题