// "Uploading " . $_FILES['userfile']['name'] . " to here: " . $_FILES['userfile']['tmp_name'] . "<br>"; if (preg_match('/^(.*)\\.xls$/', $_FILES['userfile']['name'], $matches) != 1) { print "Please upload an Excel file conforming to the Dialogix Structure"; } else { $uploadDir = '/usr/local/tomcat554/webapps/OMH/WEB-INF/schedules/'; $instrument = $matches[1] . ".txt"; $uploadFile = $uploadDir . $instrument; /* so that uploaded file is TSV equivalent of Excel file */ // print "Uploading to file $uploadFile<br>"; require_once 'Excel/reader.php'; error_reporting(E_ALL ^ E_NOTICE); // ExcelFile($filename, $encoding); $data = new Spreadsheet_Excel_Reader(); // Set output Encoding. $data->setOutputEncoding('CP1251'); $data->setDefaultFormat('%s'); $data->setColumnFormat(3, '%s'); $data->read($_FILES['userfile']['tmp_name']); $handle = fopen($uploadFile, "w"); /* replace file of same name */ if (!$handle) { print "Unable to create file <i>{$uploadFile}</i>"; } else { /* N.B. When reads in "true" or "false", converts to 1 and 0, even if set default format. So, if a reserved word, must convert back */ for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) { $row = ''; for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) { if ($j > 1) { $row .= "\t"; }