Reputation: 2472
When uploading a file through PHP - The default behavior of the interpreter is to save the file in a temporary folder, with temporary name.
Then we will have to use the function move_uploaded_file()
in order to save it permanently.
If I have access to the php code- is there a way to skip the move_uploaded_file()
phase ?
Upvotes: 1
Views: 93
Reputation: 5248
Yes and no. You can specify which directory to put the temporary files in, but not decide on the temporary name yourself.
From the docs:
Files will, by default be stored in the server's default temporary directory, unless another location has been given with the upload_tmp_dir directive in php.ini.
So you can set upload_tmp_dir:
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.
However, this merely decides the directory but not the filename itself.
I think there is pretty solid reasoning why you can't do that:
/etc/shadow
on a Linux-based system and hook into system access.Furthermore, I personally don't really see any reason why using the process with move_uploaded_file()
would be bothersome.
Upvotes: 2