与我的提供商一起上传.csv文件的问题

时间:2013-03-30 13:07:08

标签: php file file-upload csv

嘿伙计们,自从从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;

}

0 个答案:

没有答案