CyberJunkie
CyberJunkie

Reputation: 22674

Creating temp directory on server

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.

Upvotes: 1

Views: 4520

Answers (1)

Baba
Baba

Reputation: 95101

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

Upvotes: 3

Related Questions