Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change default temp directory for PHP file uploads

I'm making a website locally that allows the upload of .pdf files, when these are uploaded locally they go to C:\xampp\tmp but when I host the site on my University server I don't have access to the temporary directory, is there any way I can change the default temporary location for the file?

Thanks in advance, Dave.

like image 665
David C Avatar asked Mar 28 '13 21:03

David C


People also ask

Where are php temp files stored?

php stores all temporary files, that includes uploaded files, in the temporary files directory as specified in the php. ini. Note that for uploads, those files might be removed as soon as the script the file was uploaded to was terminated (so unless you delay that script, you probably won't see the uploaded file).

How do I change tmp folder?

To permanently set the temporary directory for a Windows user account, go to Control Panel->System->Advanced, and enter the "Environment Variables" dialog window to find and change the TEMP and TMP variable settings in the "User variables".

What is file temp name in php?

The tempnam() function creates a temporary file with a unique name in the specified directory. Note: If the specified directory does not exist, tempnam() may generate a file in the system's temporary directory. Tip: See also the tmpfile() function.

What is Upload_tmp_dir?

Overview. The temporary directory is used for storing files when a file is uploaded. This directory must be writable by whichever user PHP is running as. If not specified, PHP will use the system's default.


2 Answers

The location where uploaded files land can be configured using the upload_tmp_dir configuration option.

like image 108
Oswald Avatar answered Sep 25 '22 02:09

Oswald


Try this.

putenv('TMPDIR=/path/to/dir');

than you can check your tmp directory

sys_get_temp_dir()
like image 39
Yur Gasparyan Avatar answered Sep 26 '22 02:09

Yur Gasparyan