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.
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).
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".
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.
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.
The location where uploaded files land can be configured using the upload_tmp_dir configuration option.
Try this.
putenv('TMPDIR=/path/to/dir');
than you can check your tmp directory
sys_get_temp_dir()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With