I try to move a temporary file located in the /tmp
dir to another dir somewhere else on the server using the rename()
function. But I get an error:
Permission denied (Code: 2)
for the temporary file. How can I move a temporary file to another location? If I check that the file exists with file_exists()
I get true. And if I copy()
the temporary file it works fine.
Here's my code so far:
$toPath = '/var/www/htdocs/myproject/some/file.pdf'
$fileName = 'myfile.pdf';
$filePath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $fileName;
rename($filePath, $toPath); // Permission denied (Code: 2) here