I'm trying to upload a file from a multi-upload form. Despite the fact that the $target_file output displays the correct filepath the file doesn't being uploaded to server. Here is the code:
<?php
for ($i = 0; $i < count($_FILES['file']['tmp_name']); $i++) {
$target_dir = '../conference/files/'. $row['CONFERENCE_ID'] .'/';
$target_file = $target_dir . basename($_FILES['file']['name'][$i]);
$uploadOk = 1;
$fileTypeExtension = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if file already exists
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["file"]["name"][$i], $target_file)) {
echo "The file ". basename( $_FILES['file']['name'][$i]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file. ";
echo $target_file;
}
}
}
?>
UPDATE: I add this code to check if files are uploaded and the result is no. Any ideas why that happens?
if (is_uploaded_file($_FILES['file']['name'][$i])) {
echo "Temp file uploaded.
";
} else {
echo "Temp file not uploaded.
";
}
UPDATE 2: I tried to upload only one file and it works fine. The problem is with multiple files. Can xampp version be the problem?