I am trying to upload a file through the POST array, with the 'newFile' name from the input tag being the index in the $_POST array that contains the name of the file I am uploading. I also have a dropdown list with a different name value of 'existingFile'. When I throw a die statement on my destination location, using print_r to look at the POST array, I find that it is missing the newFile index, still has the default value of the existingFile index, and has a random '1' displaying after the rest of the array is finished with the print_r function.
<form data-ajax="false" id="formFileSubmit" method="post" action="echo.php" enctype="multipart/form-data">
<!-- Restrict file uploads that will fail -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element for upload determines name in the $_FILES array -->
<input id="fileSelect" type="file" name="newFile" onChange="checkIfFile()" />
<select id="loadFile" data-role="button" type="file" name="existingFile" data-native-menu="false" onChange="previousFile()">
<!-- Add dropdown items for every file in the uploads directory, based on Title csv file metadata -->
<option name="loadList" id="defaultLoad" value="default" selected="selected">Choose a previously saved file...</option>
<?php
//Generate options for selection list based on previously saved files
$dir = 'uploads';
$files = scandir($dir, 1);
$j = 0;
foreach($files as $fileName/* File in directory */){
if($files[$j] == 'about_uploads_folder.txt.txt' || $files[$j] == '.' || $files[$j] == '..'){
//Don't add a load option
}else{
echo "<option name='load' value='".$fileName."'>".$fileName."</options>";
echo '<br />';
}
$j++;
}
?>
What is this undefined offset error, and how do I get the 'newFile' index to show up?