CSV导入通知:未定义的索引问题

时间:2013-12-03 15:43:56

标签: php

这是一个有效的脚本。然后我改变了一些东西(我真的不知道是什么),它不再有效。我启动一个会话,然后导入一个CSV文件,该文件应该加载到一个以文件名命名的表中。以下是代码的开始方式:

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'];
        }
    }

注释代码返回存储CSV文件的正确路径。但是,当我导入CSV文件时,这是代码:

public function consumeImport(){

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){

问题是现在它正在返回错误:

注意:未定义的索引:第164行的/dataimportprocess.php中的csvFiles 警告:在第164行的/dataimportprocess.php中为foreach()提供的参数无效

有人可以帮忙吗?请?我尝试了isset,但它没有返回数组中的数据。在代码的最顶层,它确实设置了某些变量和函数:

class Import {
private $dbConnection;
private $dbSelected;
public $csvFiles;
public $csvFilesUpdate;

0 个答案:

没有答案