将大尺寸的CSV导入SQL得到此警告:fopen():文件名不能为空

时间:2017-11-04 02:37:59

标签: php sql-server csv fopen fgetcsv

我尝试将多行CSV导入到SQL中,此代码仅使用少量行(例如75行)进行导入并成功但当我尝试导入多个行(例如700000行)时)在SQL中出现。

enter image description here

if(($handle = fopen($_FILES['file']['tmp_name'], 'r')) !== false)
    {
    $header = fgetcsv($handle);
    while(($data = fgetcsv($handle)) !== false){
    $sql = "INSERT into mansfield_barcode.dbo.".$_POST['uploadSName']." values('".implode("','", $data)."')";
    $result = mssql_query($sql);
    unset($data);

    if(! $result ){
    echo "<script type=\"text/javascript\">
    alert(\"Invalid File:Please Upload CSV File.\");
    window.location = \"sku.php\"
    </script>";
    }
    }
    fclose($handle);
    echo "<script type=\"text/javascript\">
    alert(\"CSV File has been successfully Imported.\");
    window.location = \"sku.php\"
    </script>";
    }

1 个答案:

答案 0 :(得分:0)

通过更改

解决了问题
declare(ticks=1);

在php.ini中

感谢JDpawar