This was a script that worked. Then I changed something (I really don't know what) and it no longer works. I start a session and then import a CSV file(s) which should get loaded into a table named with the filename. Here's how the code starts:
public function formProcess3(){
$form_submission = false;
$form_submission_type = '';
$form_url = '';
$upload_error = false;
$upload_message = '';
$import_error = false;
$import_message = '';
// Check if there was a form submission
if(isset($_POST['type'])){
if($_FILES['uploadedfile']['name']!==''){
$form_submission = true;
$form_submission_type = $_POST['type'];
$form_url = $_POST['url'];
if(strpos($_FILES['uploadedfile']['name'], '.csv') !== false){
$upload_path = "data/";
$upload_path = $upload_path . basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $upload_path)) { }
else { $upload_error = true; }
$this->csvFiles = array($upload_path);
//echo $this->csvFiles[0];
} else {
echo "Problem";
}
} else {
$this->csvFiles = $merged['csvFiles'];
}
}
The commented code returns the correct path where the CSV file is stored. However, when I get to importing the CSV File, this is the code:
public function consumedImport(){
error_log('starting consumed import',0);
$this->consumedPrep();
error_log('done consumed prep',0);
// Loop through each csvFile and create updated csv
foreach($_SESSION['csvFiles'] as $csvFile){
The problem is that now it is returning the error:
Notice: Undefined index: csvFiles in /dataimportprocess.php on line 164 Warning: Invalid argument supplied for foreach() in /dataimportprocess.php on line 164
Can anyone help? Please? I have tried isset, but it returns no data in the array. At the very top of the code, it does set certain variables and functions:
class Import {
private $dbConnection;
private $dbSelected;
public $csvFiles;
public $csvFilesUpdate;