Devices - Import: Fix file upload.

This commit is contained in:
Nate
2020-10-20 13:14:09 -06:00
parent 58531ac7b1
commit 959a70c163

View File

@@ -66,25 +66,24 @@
//save the data to the csv file
if (isset($_POST['data'])) {
$file = $_SESSION['server']['temp']['dir']."/devices-".$_SESSION['domain_name'].".csv";
file_put_contents($file, $_POST['data']);
$_SESSION['file'] = $file;
}
//copy the csv file
//$_POST['submit'] == "Upload" &&
if ( is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('device_imports')) {
if ($_POST['type'] == 'csv') {
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']);
$save_msg = "Uploaded file to ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']);
//system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*');
unset($_POST['txtCommand']);
$file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name'];
if (file_put_contents($file, $_POST['data'])) {
$_SESSION['file'] = $file;
}
}
//copy the csv file
//$_POST['submit'] == "Upload" &&
if ( is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('device_import')) {
if ($_POST['type'] == 'csv') {
$file = $_SESSION['server']['temp']['dir']."/devices-".$_SESSION['domain_name'].".csv";
if (move_uploaded_file($_FILES['ulfile']['tmp_name'], $file)) {
$_SESSION['file'] = $file;
}
}
}
//get the schema
if (strlen($delimiter) > 0) {
if (strlen($delimiter) > 0 && file_exists($_SESSION['file'])) {
//get the first line
$line = fgets(fopen($_SESSION['file'], 'r'));
$line_fields = explode($delimiter, $line);
@@ -441,7 +440,6 @@
echo "</td>\n";
echo "</tr>\n";
/*
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_file_upload']."\n";
@@ -451,7 +449,6 @@
echo " <br />\n";
echo "</td>\n";
echo "</tr>\n";
*/
echo "</table>\n";
echo "<br><br>";