I have Apache 2.4 installed on Windows and PHP running on the same server "Windows Server 2008 R2" without using IIS.
I have a PHP script that should upload files on to the server.
Here is my PHP code
if (!empty($_FILES) && $actualToken == $verifyToken) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = ROOT_FIXED . UPLOAD_DIR . $targetFolder; //$_SERVER['DOCUMENT_ROOT']
$targetPath = str_replace( "//", "/", $targetPath);
$new_filename = USER_ID . '_' . time() . '_' . str_replace(" ", "_", $_FILES['Filedata']['name']);
$targetFile = $targetPath . $new_filename;
$fileParts = pathinfo($new_filename);
if (in_array(strtolower($fileParts['extension']),$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
$msg_res = trim($new_filename);
} else {
$msg_res = 'INVALID';
}
}
When I upload the file I do see a .tmp file created in the designated temporary folder location. But after the file is uploaded it is removed from the temporary folder but it is not being moved to the permanent location for some reason.
I am not sure if it is a permission issue or not but I am attaching screenshots of the permissions on the folders.
I have also modified the php.ini file and added
upload_tmp_dir = 'C:\php\temp_files'
so the temp files should be going into the above location "and they are."
This screenshot show the Apache is Logging on as "Local system account"
This screenshot show the security settings on the folder where the file should be permanently moved to