0

大家好,自从从 Winhost 切换到 Media Temple 后,我的 .csv 上传器一直没有工作。我正在运行一个完全专用的服务器,它都是自我管理的,当我检查系统 error_logs.file 时,我得到:

[Sat Mar 30 04:47:53 2013] [warn] [client ip] mod_fcgid: stderr: PHP Notice:  Undefined variable: seterror in mysite/getAccountsCSV.php on line 40, referer: mysite/memberinterface.php
[Sat Mar 30 04:47:53 2013] [warn] [client ip] mod_fcgid: stderr: PHP Notice:  Undefined index: csvfile in mysite/getAccountsCSV.php on line 42, referer: mysite/memberinterface.php
[Sat Mar 30 04:47:53 2013] [warn] [client ip] mod_fcgid: stderr: PHP Warning:  fopen(): Filename cannot be empty in mysite/getAccountsCSV.php on line 44, referer: mysite/memberinterface.php
[Sat Mar 30 04:47:53 2013] [warn] [client ip] mod_fcgid: stderr: PHP Warning:  fgetcsv() expects parameter 1 to be resource, boolean given in mysite/getAccountsCSV.php on line 46, referer: mysite/memberinterface.php
[Sat Mar 30 04:47:53 2013] [warn] [client ip] mod_fcgid: stderr: PHP Warning:  array_map(): Argument #2 should be an array in mysite/getAccountsCSV.php on line 48, referer: mysite/memberinterface.php
[Sat Mar 30 04:47:53 2013] [warn] [client ip] mod_fcgid: stderr: PHP Warning:  array_map(): Argument #2 should be an array in mysite/getAccountsCSV.php on line 48, referer: mysite/memberinterface.php
[Sat Mar 30 04:47:53 2013] [warn] [client ip] mod_fcgid: stderr: PHP Warning:  array_search() expects parameter 2 to be array, null given in mysite/getAccountsCSV.php on line 50, referer: ./memberinterface.php
and it keeps going....

这是我的代码:

if (!empty($_FILES['csvfile']['error'] ) )
    {

        $seterror = 1;
        returnBack();

    } 
    if (empty($_POST['firstname'])){

        $seterror =1;
        returnBack();
    }
    if (empty($_POST['lastname'])){
        $seterrro =1;

        returnBack();
    }
    if (empty($_POST['email'])){
        $seterror =1;

        returnBack();
    }
    if ($seterror != 1){

    $file = $_FILES['csvfile']['tmp_name']; 
    var_dump($file);
    $handle = fopen($file , "r");

    $fileop = fgetcsv($handle,1000,",");

    $fileop=array_map("strtoupper",array_map("trim",$fileop));

    $firstname_index = array_search(strtoupper($_POST["firstname"]),$fileop);
    if ($firstname_index===false){
        returnBack();
    }
    $lastname_index = array_search(strtoupper($_POST['lastname']),$fileop);
    if ($lastname_index===false){

        returnBack();
    }
    $email_index = array_search(strtoupper($_POST['email']),$fileop);
    if ($email_index===false){

        returnBack();
    }
        //open file and store values
        while (($fileop=fgetcsv($handle)) !== false)
        {

            $fileop=array_map("trim",$fileop);
            $firstname[$j] = $fileop[$firstname_index];
            if (empty($firstname[$j])){ 
            exit;
            returnBackfile();

            }

            $lastname[$j] = $fileop[$lastname_index];
                if (empty($lastname[$j])){
                    exit;
            returnBackfile();

            }
            $email[$j] = $fileop[$email_index];
                if (empty($email[$j])){
            exit;
            returnBackfile();


            }
            $j++;
        }

        print_r($firstname);


    }

我有一个从 jquery ui-dialog div 发送的表单.....用户可以上传文件和信息并发送到这里。如果您知道我能做些什么来解决这个问题,我将不胜感激!我不知道它是否是服务器问题,例如某些需要更改的设置或什么?

编辑:

这是 if(!empty($_FIL .....

$setereror = 0;
$j = 0;
function returnBack(){

    header("Location:../memberinterface.php?getmsg=15");
    exit;

}
function returnBackfile(){

    header("Location:../memberinterface.php?getmsg=16");
    exit;

}
4

0 回答 0