break; case 2: echo 'File exceeded max_file_size'; break; case 3: echo 'File only partially uploaded'; break; case 4: echo 'No file uploaded. try again'; break; } exit; } //call user function //get array from csv $array = importCsv($tmpFile); //create files from array ArrayCsvToFile($array); /* * function importCsv($fileCsv) does upload csv file * @param string $fileCsv patch to file csv * @return array $arrayCsv[][] field => values */ function importCsv($fileCsv) { $contents = file($fileCsv); if ($contents === FALSE) { print "cann't read from file"; exit; } $i = 0;
$filenameparts = explode("_", $_FILES['csv_name']['name']); if (isset($filenameparts[1])) { $fileid = substr($filenameparts[1], 0, -4); $filesql = "SELECT id_reqs FROM " . $xoopsDB->prefix("formulize_valid_imports") . " WHERE file='" . floatval($fileid) . "'"; $fileres = $xoopsDB->query($filesql); $filerow = $xoopsDB->fetchRow($fileres); if ($filerow[0]) { $id_reqs = unserialize($filerow[0]); } else { $id_reqs = false; } } else { $id_reqs = false; } $validateOverride = $_POST['validatedata'] == 0 ? true : false; importCsv(array($_FILES['csv_name']['name'], $csv_name), $id_reqs, $regfid, $validateOverride); print "</td></tr>\n"; } else { print "<tr><td class=head><p>" . _formulize_DE_IMPORT_STEP1 . "</p></td><td class=even>"; // provide a blank template, and a blank update template // store the id_reqs and the filename in the DB for later reference in the case of the update template // determine if this is the profile form and if so, send special flag to template creation $cols1 = getAllColList($fid, "", $groups); $cols = array(); foreach ($cols1[$fid] as $col) { $cols[] = $col['ele_id']; } $headers = getHeaders($cols); $template = $regfid == $fid ? "blankprofile" : "blank"; $blank_template = prepExport($headers, $cols, "", "comma", "", "", $template); print "<p><b>" . _formulize_DE_IMPORT_EITHEROR . "</b><p>";