将大尺寸 CSV 导入 SQL 时收到此警告:fopen():文件名不能为空
Importing large size of CSV to SQL got this Warning: fopen(): Filename cannot be empty
我尝试将多行 CSV 导入到 SQL 并且此代码仅使用少量行(例如 75 行)进行导入并且它成功但是当我尝试导入多行时出现 SQL 行(例如 700000 行)。
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>";
}
通过更改
解决了问题
post_max_size = 64M
upload_max_filesize = 64M
在php.ini
感谢 JDpawar
我尝试将多行 CSV 导入到 SQL 并且此代码仅使用少量行(例如 75 行)进行导入并且它成功但是当我尝试导入多行时出现 SQL 行(例如 700000 行)。
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>";
}
通过更改
解决了问题post_max_size = 64M
upload_max_filesize = 64M
在php.ini
感谢 JDpawar