问题
Is it possible to create a temporary directory on a hosting server with the same functionality as the tmp folder in the root directory?
I need a second tmp folder to temporary store files that I'm uploading to another web service. I want to avoid unlink()
functions or cron jobs for deleting files.
回答1:
Yes you can .... using System::mktemp
$tempfile = System::mktemp("prefix");
$tempdir = System::mktemp("-d prefix");
$tempfile = System::mktemp();
$tempfile = System::mktemp("-t /var/tmp prefix");
Or you can run the command using exec
mktemp make temporary dirname
来源:https://stackoverflow.com/questions/12874883/creating-temp-directory-on-server