php:: how long to tmp files stay?

后端 未结 3 836
终归单人心
终归单人心 2020-11-30 03:39

I am working on an upload script.

If a user uploads a file and it already exists I want to warn the user (this is all through ajax) and give them the option to repla

3条回答
  •  我在风中等你
    2020-11-30 04:25

    For uploaded files, the manual states:

    The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed.

    Files that are to be kept should therefore be moved to another location.

    More generally, as your question title might imply, temporary folders are left to be cleaned up by the system. This is true when using functions like tempnam or tmpfile, or simply when writing to the temporary directory (see sys_get_temp_dir).

    In Ubuntu, this is done at every system reboot, or at a time interval, as defined in /etc/default/rcS.

    In some Red Hat based distros, it is done using the tmpwatch utility from a cronjob. In others, the /tmp partition is mounted using the tmpfs filesystem, which is similar to a RAM disk (therefore being cleaned when the computer shuts down).

    Another known mechanism is a size threshold, which means that the temporary directory will be cleaned up from the older files when it reaches a certain size.

提交回复
热议问题