Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the temp upload path runtime?

Tags:

php

I would like to change my applications temp path to a subfolder, so that users on a shared server cannot see any uploaded files.

I would like to be able to do this run-time, or via .htaccess if possible (although I would like the new temp path to be a subdir of the original temp path). I can't edit the php.ini on the shared server.

I know I can check what the tmp path is via sys_get_temp_dir(), but there doesn't seem to be a way to set it.

Is this even possible?

like image 439
dqhendricks Avatar asked Dec 13 '22 11:12

dqhendricks


1 Answers

ini_set('upload_tmp_dir','your/path/here/'); 

The temporary directory used for storing files when doing file upload. Must be writable by whatever user PHP is running as. If not specified PHP will use the system's default.

If the directory specified here is not writable, PHP falls back to the system default temporary directory. If open_basedir is on, then the system default directory must be allowed for an upload to succeed.

upload_tmp_dir

like image 161
Shef Avatar answered Dec 30 '22 22:12

Shef